docker 共享卷
宿主机与容器共享存储
[root@docker02 ~]# docker run -it -v /var/webroot:/abc 192.168.1.21:5000/busybox
# 宿主机文件 容器文件
NFS 共享存储
创建nfs服务器
[root@localhost ~]# yum -y install nfs-utils [root@localhost ~]# vim /etc/exports /content *(rw,no_root_squash) [root@localhost ~]# systemctl restart nfs-server [root@localhost ~]# systemctl restart nfs-secure [root@localhost ~]# exportfs -rv exporting *:/content [root@localhost ~]# chmod 777 /content [root@localhost ~]# echo hello > /content/index.html
客户端
yum -y install nfs-utls systemctl restart nfs-server showmount -e 192.168.1.120 mount -t nfs 192.168.1.120:/content /mnt/qq root@docker1 ~]# docker run -d -p 80:80 -v /mnt/qq:/var/www/html -it myos:http [root@docker2 ~]# docker run -d -p 80:80 -v /mnt/qq:/var/www/html -it 192.168.1.10:5000/myos:http