Docker Community Forums

Share and learn in the Docker community.

Docker images snapshot

docker
dockerhub

(Assistanz247) #1

Hi All,

We have installed a new docker machine in centOS and launched an ubuntu container in it. Then we have installed the Apache web server.

If we run the docker commit command it takes the full snapshot of the container along with the base image.

Is it possible to take the snapshot of the updated layer to reduce the image size?

We have tried with docker save and docker export command but no luck? Is there any other command is available to take the snapshot of the updated layer from the docker images.


(David Maze) #2

You should read about the docker build command and the Dockerfile system. The Docker documentation has a good example.

If your process is (1) launch an Ubuntu container, (2) install Apache on it, (3) install some additional modules, (4) commit to a module, and then there’s an Ubuntu security patch and you need to start from a new base image, you need to run through all of these steps by hand again (and hope you did it the same way the second and third and fourth time). The Dockerfile is a straightforward script that pretty much lists out exactly these steps.

I’d recommend never using docker commit for anything, and docker import and docker export even less often.