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"
}
]