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.
You can simply perform a manual commit.
This operation is not available within the Dockerfile, but can be done manually.
When doing docker inspect <image>
, you can retrieve the ID of the container that has been used in order to create this image.
You can do then docker commit <container id> <new image name>
and all the ENV and other config will get flushed.
If the container has been removed, you can run the image docker run -d <image> <any command
, and then commit the resulting container.
If you want to keep some of the configuration, you can use the docker commit -run '{}' <container id> <new image name>
syntax. Cf http://docs.docker.io/en/latest/commandline/command/commit/ for more info.
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