I have a docker image which sets HOME and PATH:
[{
...
"config": {
"HOME=/",
}
...
I know I can replace it, but is it possible to remove it (and let the normal bash profile settings be used instead). I'd prefer not to hack the shell profile files to override it.
If you still want to use ENV to set your variable, then you'll have to start each RUN in which you want the variable to be unset with unset VAR_NAME , which will unset it for that specific RUN only.
It's not stored (in a file) anywhere. It's passed from Docker to the process running in the container.
. env files are for docker-compose. You need to use the docker-compose cli instead of just docker .
I couldn't get @creack's answer to work for me.
In my case I had inadvertently committed some environment variables to an image and I wanted to remove them from the image.
I ended up launching the image and 'unsetting' the environment variable by using -e
option with no value for the variable,
For example to unset the environment variable FOO
docker run -it -e FOO IMAGE /bin/bash
Then commit the container
docker commit -m 'removed FOO' CONTAINER_ID IMAGE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With