#自动生成新的卷 [root@localhost nginx_b1]# docker volume ls DRIVER VOLUME NAME local 25e37107425180f45d3ea8182ee738eb4e7434717bf0f4d7ef05aeef4ecb2c04 local nginx_v1 local nginx_v3
#进入卷文件夹,容器文件夹覆盖宿主机文件夹 [root@localhost nginx_b1]# cd /var/lib/docker/volumes/25e37107425180f45d3ea8182ee738eb4e7434717bf0f4d7ef05aeef4ecb2c04/_data [root@localhost _data]# ls 50x.html index.html
#创建新卷 [root@localhost _data]# docker volume create nginx_v_v2 nginx_v_v2 [root@localhost _data]# docker volume ls DRIVER VOLUME NAME local 25e37107425180f45d3ea8182ee738eb4e7434717bf0f4d7ef05aeef4ecb2c04 local nginx_v1 local nginx_v3 local nginx_v_v2
#查看现有卷 [root@localhost _data]# docker volume ls DRIVER VOLUME NAME local 25e37107425180f45d3ea8182ee738eb4e7434717bf0f4d7ef05aeef4ecb2c04 local nginx_v1 local nginx_v3 local nginx_v_v2
#运行容器,-v 具名挂载,卷不存在,自动创建成功 [root@localhost _data]# docker run -d --name nginx_c_v4 -p 8594:80 -v nginx_v_v4:/usr/share/nginx/html nginx bf4bcd3a37adaab8ad6d342088bc47297ff533b4e8a069e11b296f0d55d3f49 [root@localhost _data]# docker volume ls DRIVER VOLUME NAME local 25e37107425180f45d3ea8182ee738eb4e7434717bf0f4d7ef05aeef4ecb2c04 local nginx_v1 local nginx_v3 local nginx_v_v2 local nginx_v_v4