E-NO
Docker Desktop backup 10 Min Read

Docker Desktop Backup and Restore: A Practical Implementation Guide

calendar_today Published: 2026-09-20
update Last Updated: 2026-09-20
analytics SEO Efficiency: 100%
Technical guide illustration for Docker Desktop Backup and Restore: A Practical Implementation Guide.

Intro

Losing a local Docker environment can mean hours of rebuilding images, re-entering secrets, and recreating test data. Docker Desktop backup and restore procedures help you recover quickly, especially when you rely on persisted volumes, custom networks, or Compose projects. This guide walks through practical backup and restore techniques, validation steps, and failure recovery, focusing on Docker Desktop on Windows, macOS, and Linux.

We will cover the essential components: container data (volumes and bind mounts), images, Docker Desktop settings, and configuration files. You will learn how to inspect your current setup, create consistent backups, restore them to a new environment, and test whether your applications still work. Each section includes real commands, expected output, and troubleshooting tips.

This article is for developers, DevOps engineers, and anyone who uses Docker Desktop for local development or small-scale production. By the end, you will have a repeatable process to protect your work and reduce downtime when something goes wrong.

What to Back Up in Docker Desktop

Before running any backup command, identify what needs protection. Docker Desktop stores data in several locations, and each requires a different approach.

1. Container Data: Volumes and Bind Mounts

Most stateful applications store data in Docker volumes or bind mounts. Understanding the difference is critical for backup.

  • Docker volumes are managed by Docker and stored in a location like /var/lib/docker/volumes/ (Linux) or inside the Docker Desktop VM (macOS/Windows). You can back them up using a temporary container.
  • Bind mounts map a host directory directly into a container. They are simple to back up because the data lives on your host filesystem, but they can cause permission and portability issues.

To see which volumes or mounts a running container uses, inspect it:

docker inspect my-container --format '{{ json .Mounts }}'

Expected output (example):

[{"Type":"volume","Name":"myapp_data","Source":"/var/lib/docker/volumes/myapp_data/_data","Destination":"/var/lib/app","RW":true}]

If the mount type is bind, the source is a host path like /home/user/project/data. Back up that directory directly with standard file tools.

2. Docker Images

Images can be rebuilt from Dockerfiles or pulled from registries, but custom built images without a Dockerfile may be lost. Export important images with docker save and import them later with docker load. We will cover this later.

3. Docker Desktop Settings and Configuration

Docker Desktop stores settings such as resource limits, proxy configuration, and Kubernetes preferences. These are not included in volume backups. On macOS and Windows, settings live in files like ~/Library/Group Containers/group.com.docker/settings.json (macOS) and %APPDATA%\Docker\settings.json (Windows). On Linux, Docker Engine configuration is in /etc/docker/daemon.json. Back up these files if you customize your environment.

4. Compose Files and Environment Variables

Your docker-compose.yml and .env files define services, networks, and environment variables. They are often stored in your project repository, but if they exist only locally, include them in your backup plan.

Creating Backups: Commands and Examples

Backing Up a Docker Volume

Use a temporary container to create a tar archive of the volume's contents.

# Start a temporary container that mounts the volume, for use with --volumes-from
docker run -d --name backup-source -v myapp_data:/data alpine sleep infinity

# Create a backup of the volume 'myapp_data' using the documented --volumes-from approach
docker run --rm --volumes-from backup-source -v $(pwd):/backup alpine \
  tar czf /backup/myapp_data_backup.tar.gz -C /data .

# Remove the temporary container
docker rm -f backup-source

This command:

  • Starts a temporary Alpine container named backup-source that mounts the volume myapp_data at /data and sleeps.
  • Runs a second Alpine container with --volumes-from backup-source to access the same volume.
  • Mounts the current directory at /backup.
  • Creates a compressed tar file myapp_data_backup.tar.gz in the current directory.
  • Removes the temporary backup-source container after the backup completes.

After running, check that the backup file exists and is not empty:

ls -lh myapp_data_backup.tar.gz
# Expected: a file size greater than 0 bytes

Backing Up a Bind Mount

For a bind mount, simply copy the host directory:

# Example bind mount source: /home/user/project/data
cp -a /home/user/project/data /backup/location/data_backup

Use rsync for incremental backups:

rsync -av --delete /home/user/project/data/ /backup/location/data_backup/

Backing Up Multiple Volumes with a Script

Create a script to back up all volumes used by your containers. This example iterates over volumes from docker volume ls:

#!/bin/bash
BACKUP_DIR="$(pwd)/backups"
mkdir -p "$BACKUP_DIR"
for volume in $(docker volume ls --format '{{.Name}}'); do
  echo "Backing up volume: $volume"
  container="backup-source-${volume}"
  docker run -d --name "$container" -v "$volume":/data alpine sleep infinity
  docker run --rm --volumes-from "$container" -v "$BACKUP_DIR":/backup alpine \
    tar czf "/backup/${volume}_backup.tar.gz" -C /data .
  docker rm -f "$container"
done

Run chmod +x backup_volumes.sh and then ./backup_volumes.sh. Verify the archives in backups/.

Backing Up Images

To export one or more images:

docker save -o myapp_image.tar myapp:latest

For multiple images, list them after -o:

docker save -o all_images.tar image1:tag image2:tag

The resulting tar file can be copied to another machine.

Backing Up Configuration Files

Manually copy important config files to your backup directory:

# macOS example
cp ~/Library/Group\ Containers/group.com.docker/settings.json ./backups/docker-settings.json

# Linux example
sudo cp /etc/docker/daemon.json ./backups/daemon.json

If you use Docker contexts, back up the contexts directory:

cp -r ~/.docker/contexts ./backups/docker-contexts

Quick check 1 of 2

On Windows, which file contains the Docker Desktop VM disk and image data that should be backed up if Docker Desktop cannot launch?

The reference states that on Windows, you should back up the file %LOCALAPPDATA%\Docker\wsl\data\docker_data.vhdx.

Restoring Backups

Restoring a Docker Volume

To restore a volume from a tar archive:

# Ensure the volume exists (create if needed)
docker volume create myapp_data

# Restore data
docker run --rm -v myapp_data:/data -v $(pwd):/backup alpine \
  tar xzf /backup/myapp_data_backup.tar.gz -C /data

After restore, verify by starting the container and checking application logs.

Restoring Images

docker load -i myapp_image.tar

Confirm with docker images.

Restoring Configuration Files

Copy the backed-up files to their original locations. For Docker Desktop settings, ensure Docker Desktop is stopped before restoring to avoid overwrites:

# macOS
cp ./backups/docker-settings.json ~/Library/Group\ Containers/group.com.docker/settings.json

Restart Docker Desktop afterward.

Restoring a Compose Project

If you backed up your docker-compose.yml, restore it and run:

docker compose up -d

Check status with docker compose ps.

Verification and Diagnostics

After restoring, confirm that everything works as expected.

Basic Health Checks

Run these commands to inspect the environment:

docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
# Expected: list of running containers with status Up

docker logs my-container --tail 50
# Expected: recent logs without fatal errors

docker inspect my-container
# Check mounts, networks, and environment variables

For Compose projects:

docker compose ps
# Ensure all services are up

docker compose logs -f app
# Follow logs for the 'app' service

Testing Data Persistence

A simple restart test catches missing volumes:

docker stop my-container
docker start my-container
# Then verify data is still accessible

If data disappears, the container was likely writing to its ephemeral filesystem instead of a volume.

Verifying Volume Contents

Mount the volume in a temporary container and list files:

docker run --rm -v myapp_data:/data alpine ls -la /data

Compare with expected files.

Failure Modes and Recovery

Even with backups, restore can fail. Understand common issues and how to recover.

Permission Errors After Restore

Symptom: Container logs show Permission denied when accessing files.

Cause: The restored files have wrong ownership (e.g., root-owned when the app expects a non-root user).

Recovery: Adjust ownership inside the container or volume. For example:

docker run --rm -v myapp_data:/data alpine chown -R 1000:1000 /data

Volume Not Mounted

Symptom: Application starts but data is missing.

Cause: Wrong volume name or missing volume.

Recovery: Check docker volume ls and the container's mount configuration with docker inspect. Recreate the volume if needed.

Restore from Corrupt Archive

Symptom: Tar extraction fails or produces incomplete data.

Cause: Backup file corrupted (e.g., interrupted transfer).

Recovery: Always verify backup archives with tar tzf before trusting them. Re-run backup if possible.

Docker Desktop Settings Lost

Symptom: Resource limits or proxy settings reverted.

Cause: Restore of settings not performed or Docker Desktop updated and overwrote settings.

Recovery: Reapply from backup or manually reconfigure. Consider using docker context to manage settings.

Quick check 2 of 2

According to the reference, what must you do before backing up the Docker Desktop VM disk files?

The passage says Docker Desktop must be fully stopped before backing up these files.

Common Pitfalls and How to Avoid Them

1. Ignoring Bind Mounts in Backup Plan

Bind mounts are often forgotten because data is on the host, not in Docker volumes. Solution: Document all bind mount paths using docker inspect and include them in your backup script.

2. Backing Up a Live Database Without Consistency

A tar of a running database volume can be inconsistent. Solution: Stop the container before backup or use database-specific tools like pg_dump (PostgreSQL) or mysqldump (MySQL). Alternatively, use docker exec to run the dump command and back up the resulting file.

Example for PostgreSQL:

docker exec my-postgres pg_dump -U user mydb > db_backup.sql

3. Not Testing Restores Regularly

Backups may be invalid. Solution: Schedule a monthly restore test to a temporary environment. Automate if possible.

4. Relying on Docker Desktop's Export Feature

Docker Desktop's GUI export/import can be slow and may not include all volumes. Solution: Use command-line methods for precision and automation.

5. Storing Backups on the Same Disk

If the disk fails, backups are lost too. Solution: Copy backups to external storage or cloud.

Operations Checklist

Use this checklist to ensure a high-quality backup and restore process.

ItemResponsible RoleFrequencyVerification
Identify all volumes and bind mountsDevOps EngineerMonthlydocker inspect on all containers
Update backup script for new servicesDeveloperWhen project changesTest script in staging
Run full backupScheduled job (or manual)DailyCheck backup logs and file sizes
Verify backup archivesDevOps EngineerWeeklytar tzf or restore test
Test restore to clean environmentQA EngineerMonthlyApplication smoke tests
Review Docker Desktop settingsDevOps EngineerQuarterlyCompare current settings to backup

Assign a single owner for each row, not a group. For example, "Priya Shah, Engineering Lead" for backup policy review, revisiting quarterly.

Conclusion

Docker Desktop backup and restore is not a one-time task but an ongoing practice. By understanding what to back up, using consistent commands, and regularly testing restores, you can avoid data loss and minimize downtime. Start with a simple volume backup today, then expand to include images, configs, and automation. Remember: a backup is only as good as its last successful restore test.

As a next step, implement the volume backup script for one critical container, verify the archive, and schedule a restore test within the next week.

Related Research

Article Quality Score

Reader usefulness 100%
  • check_circle Reader-ready guide
  • check_circle Practical examples included
  • check_circle Clean SEO article URL