nfs共享存储
1.服务器创建NFS共享存储目录,权限为rw
2.客户端挂载共享,并将共享目录映射到容器种
3.docker1启动nginx
4.docker2启动apache
5.nginx和apache共享同一web目录
创建三台虚拟机
nfs 192.168.4.1
docker1 192.168.4.2
docker2 192.168.4.3
##########################################
nfs虚拟机安装nfs 192.168.4.1
# yum -y install nfs-utils
#mkdir /var/webroot #共享目录
#vim /etc/exports
/var/webroot *(rw)
#systemctl start nfs
# exportfs -avr
exporting *:/var/webroot
#chmod 777 /var/webroot
############################################
docker1 192.168.4.2
# yum -y install nfs-utils
#showmount -e 192.168.4.1 #查看
Export list for 192.168.4.1:
/var/webroot *
#mount -t nfs 192.168.4.1:/var/webroot /var/webroot
#docker run -itd -v /var/webroot:/usr/share/nginx/html myos:nginx
#echo hello > /var/webroot/index.html
#curl -i 172.17.0.2 查看
##########################################
docker 192.168.4.3
# yum -y install nfs-utils
# mkdir /var/webroot
#mount -t nfs 192.168.4.1:/var/webroot /var/webroot
#docker run -itd -v /var/webroot:/var/www/html myos:httpd
#curl -i 172.17.0.2 查看

浙公网安备 33010602011771号