首页 > 其他 > 详细

Docker-3:Data Volume

时间:2016-11-16 11:13:42      阅读:200      评论:0      收藏:0      [点我收藏+]

Add a volume

技术分享

You can also use the VOLUME instruction in a Dockerfile to add one or more new volumes to any container created from that image.

docker run -d -P --name web -v /webapp training/webapp python app.py #add a volume /webapp for container web
docker inspect web

it will shows something like

"Mounts": [
            {
                "Name": "9773d6771225964ee795b675c3c05019fae21dfa7251264eb4a8e42fbc1e5232",
                "Source": "/var/lib/docker/volumes/9773d6771225964ee795b675c3c05019fae21dfa7251264eb4a8e42fbc1e5232/_data",
                "Destination": "/webapp",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],

"Source" is the dir in the local host while "Destination" is the dir in the container.

Mount a host dir as a data volume

In addition to creating a volume using the -v flag you can also mount a directory from your Docker engine’s host into a container.

docker run -d -P --name web -v /src/webapp:/webapp:ro training/webapp python app.py

/src/webapp is the newly created dir in the host while /webapp is the dir in the container. "ro‘  means read only.

The host directory is, by its nature, host-dependent. For this reason, you can’t mount a host directory from Dockerfile because built images should be portable. A host directory wouldn’t be available on all potential hosts.

Mount a shared-storage volume as a data volume

In addition to mounting a host directory in your container, some Docker volume plugins allow you to provision and mount shared storage, such as iSCSI, NFS, or FC.

 

Docker-3:Data Volume

原文:http://www.cnblogs.com/chaseblack/p/6068495.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!