Select Page

Docker backup – Easy steps to backup and restore your containers

Docker backup – Easy steps to backup and restore your containers

Disasters cannot be predicted or prevented, but you can always quickly bounce back from them if you maintain adequate backup plans for your business.

That makes data backups indispensable for any online business. By reducing the time to restore a crashed business, backups help to save businesses and minimize the losses.

In Docker systems, containers are used to host applications or services. Today, we’ll see how to perform docker backup and restore functions for containers.

In Docker, data is categorized into two – docker images for creating containers and the container data. The container data may be stored in containers or data volumes.

Are your Docker containers insured?



How to backup Docker containers

1. Before backing up a container, you need to identify its container ID. To know the container ID of a Docker instance, you can list the containers in that system.

The containers in a Docker machine can be listed using the command ‘docker ps’.

Docker backup - container list

Docker container list


2. To backup a container in this list, use the ‘docker commit’ command with the following syntax:

docker commit -p container-ID backup-name

The container ID can be obtained from the ‘docker ps’ list and the ‘backup-name’ can be chosen based on your backup policy.

Docker backup of container

Take backup of Docker container


This snippet shows the docker backup of container ‘679facd4ee38’ (WordPress container), being taken in the name ‘backup-01’.

3. The backup image of the container, also known as ‘snapshot’, would be created with the name ‘backup-01’ and will be listed in the ‘docker images’ list:


Docker backup of container image

Docker container backup image


This image of the container can be used to restore it on a later point and retrieve the state of the container to that moment this snapshot was taken.

4. It is not advisable to store the backups in the same Docker host machine as the container, as a hardware crash in it can tamper with the backups too.

So we usually convert these backup images to compressed formats such as ‘tar’ files and copy them over to an external server.

The ‘tar’ file for the backup image can be generated using the command:

docker save -o backup-name.tar backup-name

5. The tar file would be generated as shown, which can be copied over to external locations using ‘rsync’ or ‘scp’ tools.

Container backup image compressed file

Compressed tar file of container backup image


Tools such as docker-backup can also be configured to take docker backup of containers. At Bobcares, we use custom scripts to perform backups.

The docker backup scripts are compiled based on parameters such as backup frequency, storage location, priority and importance of the container, etc.

[ Running a Docker infrastructure doesn’t have to be hard, or costly. Get world class Docker management services at affordable pricing. ]

Looking for a stable Docker setup?

Talk to our Docker specialists today to know how we can keep your containers top notch!




  1. Very Helpful Article Keep up the good work. We need heroes like you in the world!

    • True

    • Thank you for your kind words, Sean 🙂

  2. Awesome… fantastic… fabulous… great work…
    Thank you

    • Thank you for your kind words, Priya 🙂

  3. Hi Guys,

    How to backup a container with multiple “data-directory”?


    // Jonas

    • Jonas,

      It is also possible to backup data volumes. Please submit your details at and our docker experts would configure the backups for you.

  4. after running:
    docker run –rm –volumes-from new-container-name -v $(pwd):/backup ubuntu bash -c “cd /data-directory && tar xvf /backup/backup.tar –strip 1”

    I wasn’t able to run/start my container.

    I’m using jenkins as my base image.

  5. Nice tutorial it’s been very useful !!!

  6. Bob, you care, thank you for this.

  7. Hi,
    i have an issue when we backup windows container volume it gives an error:
    PS C:\WINDOWS\system32> docker run –volumes-from volcontainer -v C:/backup myservercore tar -cvf c:/backup/backup.tar /c:/wincorevolume
    C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 83cddcbc17e458abbd2bf97ca788ad8d664e3a3b72bca3301f2a9a9abc12485a encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {“CommandLine”:”tar -cvf c:/backup/backup.tar /c:/wincorevolume”,”WorkingDirectory”:”C:\\”,”CreateStdInPipe”:true,”CreateStdOutPipe”:true,”CreateStdErrPipe”:true,”ConsoleSize”:[0,0]}.
    PS C:\WINDOWS\system32>
    Can u please give me suggestion how to backup volume

  8. please share backup and restore volume container on windows


Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.