Backing up data volume containers off machine

2019-06-03 01:29发布

问题:

when reading this:

https://docs.docker.com/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes

Am I correct in the thinking that tar file they're referencing is still isolated in containers, and these examples aren't demonstrating anyway to preserve state after a machine loss?

Or is there a mental leap I'm not making with due to my ignorance?

回答1:

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.

So:

Am I correct in the thinking that tar file they're referencing is still isolated in containers

No, it is on pwd (on the host hard drive current working directory), since pwd was mounted as /backup in the ubuntu container where the tar occurred.

An ls of the current working directory will list backup.tar, once the container ubuntu exits.



标签: docker