I am trying to run a docker container via the docker run command. I am specifying an environment variable via the -e flag. The strange thing is that I am able to read that environment variable if I exec /bin/bash into the container, but not in the entrypoint script as defined in the Dockerfile.
My docker container has debian:9 as the base and the entrypoint script is a simple bash script that logs some data along with the environment variable.
RUN apt-get update && apt-get install -y curl sudo supervisor wget
ADD starter-service.sh .
RUN chmod 755 starter-service.sh
ENTRYPOINT ["sudo", "/bin/bash", "-c", "./starter-service.sh"]
if [ "$license" == "" ]
echo "No License Key: "$LICENSE_KEY" arg:"$arg > /tmp/my-service.log
printenv >> /tmp/my-service.log
The environment variable in question is LICENSE_KEY. Docker run command:
docker run -e LICENSE_KEY=123 <docker image>
The environment variable is not visible in the starter-service script.
p.s: also posted on stackoverflow (https://stackoverflow.com/questions/50490402/environment-variable-passed-through-e-flag-in-docker-container-not-accessible-i)