Docker volume: backup

此生再无相见时 提交于 2019-12-04 14:55:40
VonC

Simply don't use data volume container: since docker 1.9, you can use docker volume create instead. Docker now has volume commands.

The following example also creates the my-named-volume volume, this time using the docker volume create command.

$ docker volume create --name my-named-volume -o size=20GB
$ docker run -d -P \
  -v my-named-volume:/opt/webapp \
  --name web training/webapp python app.py

Those volumes are named, listed by docker volume ls, and you can backup /var/lib/docker/volumes.

With data volume container, you would need to memorize the path of the data within that container (docker inspect -f '{{ (index .Mounts 0).Source }}), write it to a file, and use that path when you create a new data volume container.
I used to do that with updateDataContainerPath.sh. See "Reattaching orphaned docker volumes".

I do not need that convoluted mechanism since docker 1.9 and named volumes.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!