docker volume 子命令使用:
Commands:
create Create a volume
inspect Display detailed information on one or more volumes
ls List volumes
prune Remove all unused local volumes
rm Remove one or more volumes
创建一个test_date数据卷:docker volume create test_date
查看数据卷详细信息:docker volume inspect test_date
创建一个容器,使用这个数据卷:docker container run -itd --name nginx-test --mount src=test_date,dst=/usr/share/nginx/html nginx:1.11
第二种方法使用-v选项:docker container run -itd -p 8081:80 --name nginx-test2 -v test_date:/usr/share/nginx/html nginx:1.11
清理数据卷:先暂停容器,删除容器,然后在删除数据卷
docker container stop nginx-test
docker container rm nginx-test
docker volume rm test_date
原文:https://blog.51cto.com/8922100/2480748