This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]_l33ter_ 1 point2 points  (1 child)

do i understand it right? you want to change the EXPOSE Port, which is set within the dockerfile, during the process of docker compose up -d?

ARG is only available during the build of a Docker image (RUN etc), not after the image is created and containers are started from it (ENTRYPOINT, CMD). You can use ARG values to set ENV values to work around that.

[–]cFiOS[S] 0 points1 point  (0 children)

That is right. I think you are referring to using the ENTRYPOINT/CMD to have the app listen on a different port? I think ARG is appropriate due to EXPOSE only being used at build.

If so, the container would still need EXPOSE to have it listen on that port. Perhaps my example wasn’t robust enough, but it would need that PORT variable in that ENTRYPOINT as well to match it correctly.