Docker Tip #12 - Use docker commit to customize your image

Imagine you have a docker image that you need to customize because you want to turn some debugging on. Do you need to create a new Dockerfile and trigger a new build? No you do not, there is a nice feature in Docker that allows you to commit changes to an existing image that will result in another new image.


    docker commit --change "ENV DEBUG true" image_id
        

The above example adds DEBUG=true as if it was part of a ENV statement in the Dockerfile. Note the command line will return the image_id of the new image with DEBUG=true in there. Then you can use the new image_id to run.

See the Docker documentation for what type of statements are supported.

Posted September 12, 2016

Up