Skip to content

Instantly share code, notes, and snippets.

@l3x
Last active June 9, 2020 15:00
Show Gist options
  • Save l3x/c5632892282f99ba401dc326a7f06223 to your computer and use it in GitHub Desktop.
Save l3x/c5632892282f99ba401dc326a7f06223 to your computer and use it in GitHub Desktop.
Docker Examples

Data Containers

Backup a data container to a .tar file in current, local, working directory.

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

Here we’ve launched a new container and mounted the volume from the dbdata container.

We’ve then mounted a local host directory as /backup.

Finally, we’ve passed a command that uses tar to backup the contents of the dbdata volume to a backup.tar file inside our /backup directory.

When the command completes and the container stops we’ll be left with a backup of our dbdata volume.

https://stackoverflow.com/questions/34357252/docker-data-volume-vs-mounted-host-directory

List Volume Mounts in Container

docker inspect <CONTAINER_ID> | jq .[] | jq .Mounts[]

https://stackoverflow.com/questions/30133664/how-do-you-list-volumes-in-docker-containers/62285540#62285540

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment