从机器上备份数据卷容器 [英] Backing up data volume containers off machine
问题描述
阅读此文件时:
https://docs.docker.com/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes
我认为他们引用的tar文件在容器中仍然是孤立的,而这些示例在机器丢失后仍然没有显示出来保存状态?
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?
推荐答案
docker run --volumes-from dbdata -v $(pwd):/backup \
ubuntu tar cvf /backup/backup.tar /dbdata
这里:
Here:
- 我们已经启动了一个新的容器,并从
dbdata
容器中装入卷。 - 我们已经将本地主机目录安装为
/ backup
。 - 最后,我们传递了一个使用tar将
dbdata
卷的内容备份到backup.tar
我们的/ backup
目录中的文件。
当命令完成并且容器停止时,我们将留下我们的dbdata
卷的备份。
- 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 abackup.tar
file inside our/backup
directory.
When the command completes and the container stops we’ll be left with a backup of ourdbdata
volume.
所以:
我正在考虑到他们引用的tar文件在容器中仍然是隔离的。 b $ b
Am I correct in the thinking that tar file they're referencing is still isolated in containers
不,它是在pwd(在主机硬盘驱动器当前工作目录下),因为pwd被挂载为 / backup
在发生tar的ubuntu容器中。
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.
当前工作目录的一个ls将列出 backup.tar
,一旦容器ubuntu退出。
An ls of the current working directory will list backup.tar
, once the container ubuntu exits.
这篇关于从机器上备份数据卷容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!