How to Backup and Restore Docker Containers and Volumes


Docker has revolutionized the way we develop, package, and deploy applications. But like any system, it’s crucial to have backups. In this post, we’ll walk through the process of backing up Docker containers and volumes to an external hard drive and restoring them on another Docker server.

Backing Up Docker Containers:

  1. Commit the Container:
    Before you can backup a container, you need to commit any changes made inside it to an image.
   docker commit <container_id> <backup_image_name>
  1. Save the Image:
    Once committed, save the image to a tarball.
   docker save -o <path_to_backup_image.tar> <backup_image_name>

Backing Up Docker Volumes:

  1. Locate the Volume:
    Identify where Docker stores its volume data.
   docker volume inspect <volume_name>

Look for the “Mountpoint” in the output.

  1. Copy the Data:
    Copy the volume data to your external hard drive.
   sudo cp -r <mountpoint_path> /path/to/external/hdrive/

Restoring on Another Docker Server:

  1. Load the Image:
    Transfer the tarball to the new Docker server and load the image.
   docker load -i <path_to_backup_image.tar>
  1. Run the Container:
    Create and run a new container from the backed-up image.
   docker run -d <backup_image_name>
  1. Restore Volume Data:
    Copy the volume data from your external hard drive to the appropriate location on the new Docker server.


While Docker provides a seamless environment for application development and deployment, ensuring data safety is paramount. Regularly backing up containers and volumes ensures that you can quickly recover from unforeseen issues. Whether you’re migrating to a new server or recovering from a disaster, these steps will help you restore your Docker environment with ease.

I hope this blog post provides a clear guide on backing up and restoring Docker containers and volumes. Always remember to test your backups to ensure they can be restored correctly. Happy Dockering!

You may also like...