Search code examples
dockercontainersbackup

Docker image is getting bigger and bigger


right now I'm experimenting with Docker.

I have "installed" a Docker Debian Image. In this Debian Environment, I installed a application.

Now, I do every night this:

  • docker stop (stop container)
  • docker commit (make container to an image)
  • docker save (to save the image to an file, I do this to backup the current work)
  • docker run (to start the container)

So as you can see, I try to create a "backup-solution".

It works perfectly. But the problem is, that the backup-files are getting bigger and bigger by every day. Even without touchting the container for multiple days.

It used to be well under 10 gigabytes, but now it's already 20.

Why is that? What am I doing wrong?

Thanks a lot


Solution

  • Docker images save "diffs" every commit you make, along with all previous versions of your image. This means that your process is guaranteed to steadily increase your final image size. To avoid this, instead of using docker save, you should use docker export instead (which receives the container as an argument, instead of an image).

    Docker save

    Docker export