六、Docker 存储卷(volume)
COW:写时复制
- Bind mount volume:手动mount绑定的卷
# docker run --name centos-3 -it -v /data centos:centos7.5.1804
# docker inspect 638374f203ab |grep -A 10 Mounts
- Docker-managed volume:docker自动管理的卷
# docker run --name centos-4 -it --rm -v /data/volumes/centos-4:/data centos:centos7.5.1804
# docker inspect -f {{.Mounts}} centos-4 #指定js模板查看数据
[{bind /data/volumes/centos-4 /data true rprivate}]
# docker inspect -f {{.NetworkSettings.IPAddress}} centos-4
- 共享volume
# docker run --name centos-5 -it --rm -v /data/volumes/centos-share:/data centos:centos7.5.1804
# docker run --name centos-6 -it --rm -v /data/volumes/centos-share:/data centos:centos7.5.1804
- 复制其他容器的卷设置
# docker run --name infracon -it -v /data/infracon/volume/:/data/web/html centos:centos7.5.1804 基础架构支持容器
# docker run --name nginx --network container:infracon --volumes-from infracon -it nginx