Can anyone explain why is the environment variable passed by
docker run --rm -it -e APP_PORT=80 -p 8080:80 my_container <image-id>
to CMD in Dockerfile is not resolved in following cases:
...
ARG APP_PORT
ENV APP_PORT=${APP_PORT}
...
CMD ['gunicorn', "-b", "0.0.0.0:${APP_PORT}", "main:app"] # DOES NOT WORK!
CMD ['gunicorn', "-b", "0.0.0.0:$APP_PORT", "main:app"] # DOES NOT WORK!
CMD ["sh", "-c", "echo 0.0.0.0:$APP_PORT"] # WORKS!
CMD gunicorn -b 0.0.0.0:$APP_PORT main:app # WORKS!
DOES NOT WORK!
means I get the error: Container log - Error: '$APP_PORT' is not a valid port number.