Golden Codes - armanexplorer planet

Practical code snippets for Django, Python, Bash, Git and All!

View on GitHub

mount types

Docker Volumes (new style)

Docker Bind Mount (old style)

In Memory Mount

docker inspect mycontainer --format ''

Back up, restore, or migrate data volumes

# source container
docker run -v /dbdata --name dbstore ubuntu /bin/bash

# backup
docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata

# create new container and restore
docker run -v /dbdata --name dbstore2 ubuntu /bin/bash
docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /dbdata && tar xvf /backup/backup.tar --strip 1"

--strip 1: It tells tar to remove one leading directory level from the filenames during extraction.