Last active
May 11, 2016 09:44
-
-
Save marc-harry/f66e35364bea6daa87ec9d999039a3aa to your computer and use it in GitHub Desktop.
List of docker commands for use with volumes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create Volume | |
| docker create -v /var/lib/postgresql/data --name pgres2 busybox | |
| // Remove Volume | |
| docker rm pgres2 | |
| // List files in volume directory | |
| docker run --rm --volumes-from pgres2 busybox ls -lh /var | |
| // Make backup | |
| docker run --rm --volumes-from pgres -v (<host-dir> or $(pwd)):~/ busybox tar cvf /backup/backup.tar /var/lib/postgresql/data | |
| // Restore Backup | |
| docker run --rm --volumes-from pgres2 -v <host-dir>:/backup ubuntu bash -c "cd /var/lib/postgresql/data && tar xvf /backup/backup.tar --strip 1" | |
| docker run --rm --volumes-from pgres2 -v /c/Users/marc.harry/:/backup busybox tar xvf /backup/backup.tar | |
| // Run Docker container with Volume | |
| docker run --name postgres -d --volumes-from pgres2 -p 5432:5432 postgres | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment