Docker
Volumes Commands
Persist and share data between containers and the host. Learn volume types, backup strategies, and best practices for managing stateful applications in Docker.
9 commands
Pro Tips
Use named volumes for production data and bind mounts for development (hot reload of code).
Backup volumes with: docker run --rm -v volume:/data -v $(pwd):/backup alpine tar czf /backup/backup.tar.gz /data
Use 'docker volume ls -f dangling=true' to find unused volumes taking up disk space.
Common Mistakes
Deleting a container does not delete its volumes. Use 'docker volume prune' to clean up orphaned volumes.
Bind mounting host directories exposes the host filesystem - be careful with permissions and paths.