$ docker run -d -P --name nginx01 -v /etc/nginx nginx
查看已挂载的卷:
1 2 3 4 5 6
$ docker volume ls DRIVER VOLUME NAME local b3b5c49a7b70d051d7e6016315802e0e76e2fcf51c6f063154e6003ea4bacc64 local c2e4e840333c3822a97c72237aa193a5c86117814d3d650b784a4ebde775dafc local cout-test-vol
具名挂载示例:
-v后面的格式是主机卷名称:容器内目录
1
$ docker run -d -P --name nginx02 -v test-nginx:/etc/nginx nginx
再次查看已挂载的卷:
1 2 3 4 5 6
$ docker volume ls DRIVER VOLUME NAME local b3b5c49a7b70d051d7e6016315802e0e76e2fcf51c6f063154e6003ea4bacc64 local c2e4e840333c3822a97c72237aa193a5c86117814d3d650b784a4ebde775dafc local cout-test-vol local test-nginx