Docker实现nfs共享存储

准备环境:

  1.三台机器

    1.1 nfs服务器       ip地址:192.168.113.254  主机名:nfs

    1.2 docker主机1   ip地址:192.168.113.11     主机名:docker1

  2.准备镜像 myos:http(可参考另一篇文章制作,docker自定义镜像)

 

操作步骤:

1.nfs服务器配置

[root@nfs ~]# yum -y install nfs-utils
[root@nfs ~]# mkdir /content
[root@nfs ~]# vim /etc/exports
/content    *(rw)
[root@nfs ~]# exportfs -rv
exporting *:/content
[root@nfs ~]# chmod 777 /content
[root@nfs ~]# echo 11 > /content/index.html
[root@nfs ~]# systemctl stop firewalld
[root@nfs ~]# systemctl disable firewalld

2.docker主机配置

[root@docker1 oo]# yum -y install nfs-utils
[root@docker1 oo]# systemctl restart nfs-server
[root@docker1 oo]# showmount -e 192.168.113.254
[root@docker1 oo]# mkdir /mnt/qq
[root@docker1 oo]# mount -t nfs 192.168.113.254:/content /mnt/qq
[root@docker1 oo]# cat /mnt/qq/index.html 
11
[root@docker1 oo]# docker run -d -p 80:80 -v /mnt/qq:/var/www/html -it myos:http
e9e4271387dc408ee378fbf4ad373c0d4fe8a101394a33fbdcaeadfaf6bbcdd3
[root@docker1 oo]# curl 192.168.113.11
11

转载于:https://www.cnblogs.com/luoposhanchenpingan/p/10845222.html

你可能感兴趣的:(Docker实现nfs共享存储)