Docker数据卷挂载

时间:2021-07-06 16:28:50   收藏:0   阅读:0

1. 匿名挂载

[root@VM-16-3-centos ~]# docker run -d --name nginx02 -p 80:80 -v /etc/nginx nginx

[root@VM-16-3-centos ~]# docker volume ls
DRIVER VOLUME NAME
local 5af5b9b4d1976282681cbc9eab47918efe4fa48ed73ad06e3fde8dff3b20215f
local f027ba08adf2631ebc92b4aad3bf51e880ff2bf6c06081693a11b79275b4d94e

2.具名挂载

[root@VM-16-3-centos ~]# docker run -d --name nginx03 -p 80:80 -v helloworld:/etc/nginx nginx

[root@VM-16-3-centos ~]# docker volume ls
DRIVER VOLUME NAME
local 5af5b9b4d1976282681cbc9eab47918efe4fa48ed73ad06e3fde8dff3b20215f
local f027ba08adf2631ebc92b4aad3bf51e880ff2bf6c06081693a11b79275b4d94e
local helloworld

3. 查看挂载的具名在宿主机中的位置

[root@VM-16-3-centos ~]# docker volume inspect helloworld
[
{
"CreatedAt": "2021-07-06T14:54:52+08:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/helloworld/_data",
"Name": "helloworld",
"Options": null,
"Scope": "local"
}
]

技术图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!