I am puzzled by a strange behavior I noticed in one of my images. I use docker in a way that is not idiomatic, I need to create a runtime user that matches the one of the host during the initialization of the container.
I am wondering how the environment variables passed to the container are treated, and where they are stored. I couldn’t find this information anywhere.
$ docker pull diegoferigo/devenv $ docker run -it --rm \ -e USERNAME=$(whoami) -e FOO="bar" \ diegoferigo/devenv su $(whoami) $ env | grep FOO FOO=bar $ sudo su [sudo] password for dferigo: SAME AS USERNAME # env | grep FOO # No output, the variables are not exported in this shell
In the beginning I thought that in the initialization of the container, the env vars defined in the Dockerfile and the ones passed through the command line were stored in one of the usual files read by the shell. However, I couldn’t find them in any of these files (profile, environment, bashrc, etc).
Is there any way I can get them from within the container?