码迷,mamicode.com
首页 > 其他好文 > 详细

Docker-3:Data Volume

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

标签:ora   class   volume   nbsp   iscsi   str   container   mount   name   

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

标签:ora   class   volume   nbsp   iscsi   str   container   mount   name   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!