Listening on $PORT with docker image
I'm trying to run https://hub.docker.com/r/sundowndev/phoneinfoga but am not able to listen on the railway PORT.
While debugging, using
echo $PORT
as the start command just prints $PORT, which seems to indicate that $PORT is not defined?8 Replies
Project ID:
b3abd4e5-22bc-4778-8218-bceb341997df
Solution
There's no variable expansion in exec mode
Found a workaround by calling it in
sh -c
yea, wrapping it in shell is a nice workaround
On a "normal" github service, variable expansion works fine tho
you can also set a static port by specifying the static port you set in your service variables
if you choose to use port
5000
like in the docker image then you just set thePORT
service variable to 5000
but executing it in shell is completely fine tooHow come on a docker service,
echo $PORT
as a start command doesn't print the PORT but does on a custom github service?When you build a docker service and set a custom start command, it sets that start command in the docker image's
ENTRYPOINT
in exec form, which is why variable expansion does not work
When you deploy a github service that doesn't have a Dockerfile, you'll be using Nixpacks
I think nixpacks just runs the start command in some kind of launch process where it's likely run in shell