In my docker file am I modifying /etc/environment file to create system-wide environment variables.
When I run the image the value of these variables are empty (they are simply not set); However, if I ssh into the container they are set as expected.
What could be a reason for it?
How did you try to read the variable from the running container?
You can use
ENV in Dockerfile to set environment variables.
I’m having a similar issue although I’m just trying to use existing environment variables. I don’t want to set environment variables.
I’m using CMD to run a shell script which uses ORACLE_HOME environment variable. When Docker runs the script ORACLE_HOME has no value. If I start the container with the bash shell (docker run -i -t … /bin/bash) the script works perfectly. ORACLE_HOME environment variable points to the Oracle installation.
I could use ENV in the dockerfile to point to the oracle installation but then that defeats the whole purpose of Oracle using Linux environment variables. If the oracle installation changes I would have to change the docker file when in reality I shouldn’t have to.
Can anyone shed some light on this issue?
Basically it depends on how your format your CMD in your docker file, details can be found documented here. but sounds like you guys want to run your command in the “shell” format way
I’ve faced with the same issue. Unfortunately the link is not valid anymore. Could you give an another link?