如有错误,敬请谅解!
此文章仅为本人学习笔记,仅供参考,如有冒犯,请联系作者删除!!!
作业要求:
1、画出docker command的思维导图
2、运行一个nginx的容器,要求如下:将容器的80端口映射到宿主机的8000端口,并将数据卷my-volume挂载到/usr/share/nginx/html目录
3、运行一个httpd的容器,要求如下:将容器的80端口映射到宿主机的8001端口,并将数据库my-volume挂载到/var/www/html
4、进入容器httpd,修改/var/www/html/index.html文件的内容为welcome to httpd
5、使用curl命令或者浏览器访问nginx容器和httpd容器的web页面
1、画出docker command的思维导图
![](https://img-blog.csdnimg.cn/cb615def4ad3498ebca24943f93b8b69.jpeg)
2、运行一个nginx的容器,要求如下:将容器的80端口映射到宿主机的8000端口,并将数据卷my-volume挂载到/usr/share/nginx/html目录
[root@localhost ~]# docker volume create my-volume
my-volume
[root@localhost ~]# docker run --name webl -v my-volume:/usr/share/nginx/html -d -p 8000:80 nginx
379be6549e65f0a8635c44424c50ab8f10eea82d4a1e2b394dbf1e853d7118f8
3、运行一个httpd的容器,要求如下:将容器的80端口映射到宿主机的8001端口,并将数据库my-volume挂载到/var/www/html
[root@localhost ~]# docker run -d -p 8002:80 --name httpd -v my-volume:/var/www/html httpd
0f8ebd0fc2ed836a39e9e954cc704bc963ffb650a4d00e1feb372a82aef6dc04
4、进入容器httpd,修改/var/www/html/index.html文件的内容为welcome to httpd
[root@localhost ~]# docker exec -i -t httpd bash
root@0f8ebd0fc2ed:/usr/local/apache2# echo "welcome to httpd"> /var/www/html/index.html
root@0f8ebd0fc2ed:/usr/local/apache2#
5、使用curl命令或者浏览器访问nginx容器和httpd容器的web页面
[root@localhost ~]# curl 172.17.0.3
welcome to httpd