Docker卷容器小实验

实验环境:centos7.4

卷容器:172.17.0.2
web1:    172.17.0.3

web2:    172.17.0.4

====================================

1.用已有镜像文件创建卷容器(/var/www/html 为共享目录,会自动创建

[[email protected] ~]# docker run -it -d -v /var/www/html --name dbdata  centos7.4 /bin/bash

cb446e48d64de31c536b1fdba41b30279454ef2d31c65b358ac9ca23789efa48


2.可以登录卷容器,touch一个文件

[[email protected] ~]# docker exec -it dbdata /bin/bash
[[email protected] /]# ls /var/www/html/
[[email protected] /]# cd
[[email protected] ~]# cd /var/www/html/

[[email protected] html]# touch index.html


3.创建2个web容器(dbdata为卷容器名称)
[[email protected] ~]# docker run -it -d --volumes-from dbdata --name web1 centos7.4_ssh /bin/bash
fd5ff241c5fbee79aaceb1bffc19555cc0e180ee0e139453cf2c3eff5c5fc415
[[email protected] ~]# docker run -it -d --volumes-from dbdata --name web2 centos7.4_ssh /bin/bash

2f6cd6bf82137e2285757778de52c31d19dba5122b402c1e620b1eab5637fe1c


4.登录web容器查看测试
[[email protected] ~]# docker exec -it web1 /bin/bash
[[email protected] /]# ls /var/www/html/
index.html

相关文章:

  • 2021-07-09
猜你喜欢
  • 2021-07-13
  • 2022-02-24
  • 2021-11-20
  • 2021-06-10
  • 2021-06-23
  • 2021-05-13
  • 2021-06-15
相关资源
相似解决方案