How to back up Docker containers and volumes
Updated 11/29/2026
Containers are easy to recreate from images, but the data in volumes is what matters. Here is how to save it.
1. Back up a volume
Run a temporary container that archives the volume:
docker run --rm -v app_data:/data -v $(pwd):/backup alpine \
tar czf /backup/app_data.tar.gz -C /data .
2. Restore
docker run --rm -v app_data:/data -v $(pwd):/backup alpine \
tar xzf /backup/app_data.tar.gz -C /data
3. Save the configuration too
Keep the compose.yaml and .env files in git or a separate backup. With those plus the volumes, you can rebuild everything.
4. Send the backup off the server
A backup on the same server does not help if the server fails. Copy the archives to a Backup Box, mounted as an extra disk:
rsync -a app_data.tar.gz /mnt/backup/docker/
5. Automate
Put the backup script in cron, see automated backups with cron.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How networking works in Docker
Understand how containers communicate with each other and how to isolate them on separate Docker networks.
Updated 11/29/2026Docker & containersHow to keep data in Docker with volumes
Containers are ephemeral: without volumes, you lose data when you delete the container. Here is how to keep it correctly.
Updated 11/29/2026Docker & containersHow to free up disk space used by Docker
Images, stopped containers and orphaned volumes can fill your disk. Here is how to clean them up safely.
Updated 11/29/2026