Context
I'm using environment variables with docker to configure my applications. This way a single built image can serve many different users who will need different configurations.
When developing, I often enter the container and perform a few tweaks before restarting Apache. This could be something like editing the php.ini file to turn on debugging info. However, if I do this, PHP loses access to all of the environment variables that have been set, and the application stops working.
Question
Is there a way I can restart the Apache server within a docker container, and maintain access to all of the environment variables in PHP that were passed in at deployment with docker run ... -e foo=bar
?
Extra Info
The script I use to enter the docker is shown below:
#!/bin/bash
EXPECTED_NUM_ARGS=1;
if [ "$#" -ne $EXPECTED_NUM_ARGS ]; then
# user didn't specify which container ID, assume the latest one
CONTAINER_ID=`/usr/bin/docker ps -q --no-trunc | /bin/sed -n 1p`
/usr/bin/docker exec -it $CONTAINER_ID env TERM=xterm bash
else
# enter the container the user specified
/usr/bin/docker exec -it $1 env TERM=xterm bash
fi
In case it matters, I am not using Apache as the foreground process of the container, thus I can restart Apache without the container stopping.