You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to add a environment variable, TESTVAR, into /etc/environment or /etc/profile in my Debian 8 container. The files was successfully modified. Then
commit the container to the image
stop the container
run a new container from the newly committed image
docker exec -u 0 -it bash.
I have noticed that the file /etc/environment or /etc/profile has changed, but echo $TESTVAR outputs nothing.
I am confused why the above steps did not work. Can anybody help? Thanks!
The text was updated successfully, but these errors were encountered:
However, the standard way to set environment variables, is to use the -e option on Docker run, or set ENV inside a Dockerfile
I'll close this issue, because this is a question, not a bug, and our issue tracker is not intended as a general support forum (better ask in forums.docker.com, or in the #docker IRC channel), but I hope this helps
For anyone else attempting this, setting them in /etc/bash.bashrc doesn't work either. You'll have to explicitly source the file you've written to in order to get those environment variables available for your command/script/whatnot, e.g. docker run mycontainer bash -c 'source /etc/environment && env'.
However, the standard way to set environment variables, is to use the -e option on Docker run, or set ENV inside a Dockerfile
Just to clarify our use case, there are situations where we need to set envvars after the container has started rather than at compile time through the CLI, so neither of those solutions will work for us. For example, setting an envvar based on the container's hostname.
Hi folks,
I am trying to add a environment variable, TESTVAR, into /etc/environment or /etc/profile in my Debian 8 container. The files was successfully modified. Then
I have noticed that the file /etc/environment or /etc/profile has changed, but echo $TESTVAR outputs nothing.
I am confused why the above steps did not work. Can anybody help? Thanks!
The text was updated successfully, but these errors were encountered: