Hi, was wondering if anyone else is experiencing the same issue with environment variables defined at run of an image not being passed to running container.
running like below works… But not from a detached container…
docker run -ti -e “FOO=YOU” oraclelinux-systemd/7.1:base /bin/bash
[root@8224edf2ee2d /]# env
HOSTNAME=8224edf2ee2d
TERM=xterm
FOO=YOU
NO_PROXY=localhost,127.0.0.1
…
…
I expect that init(8) is completely resetting the environment.
You might consider revisiting your overall approach to building this container. None of the containers I build run an init, install an sshd, set a root password, or require --privileged to run. These are much simpler to set up and don’t insecurely reuse keys. If I do need a shell within a running container, docker exec can provide that.
(Anyone who can get a copy of your image can run docker history to find its root password, if you’re reusing this setup in other environments and/or distributing it to customers.)
This was a simple example… This is for an internal only project building some bits on the fly…
The users need the ability to have sshd running as well as autofs installed… In oracle linux 6 containers this use to work out of box… Once I switched to oraclelinux 7 it stopped working… Thus the steps to install/configure a container as such… The password… I agree, this was just a simple example.
In order to have sshd I need to run it --privileged mode. The init script starts up the services. Not sure of any other way to do that…
I believe what is happening is the environment variables set are being passed to the init script and not to a default shell.