2、运行一个nginx的容器,要求如下:将容器的80端口映射到宿主机的8000端口,并将数据卷my-volume挂载到/usr/share/nginx/html目录
(1)创建数据卷my-volume
[root@server ~]# docker volume create my-volume
my-volume
(2) 运行容器并挂载
[root@server ~]# docker run --name web1 -d -p 8000:80 -v my-volume:/usr/share/nginx/html nginx:latest
3、运行一个httpd的容器,要求如下:将容器的80端口映射到宿主机的8001端口,并将数据库my-volume挂载到/var/www/html
[root@server ~]# docker run --name web1_httpd -d -p 8001:80 -v my-volume:/var/www/html httpd:latest
4、进入容器httpd,修改/var/www/html/index.html文件的内容为welcome to httpd
(1)交互式进入容器(该容器已经在运行)
[root@server ~]# docker exec -it web1_httpd bash
(2)修改文件内容
root@569af2fb3c73:/usr/local/apache2# echo welcome to httpd > htdocs/index.html
以容器的方式运行httpd,默认访问的HTML页面不再/var/www/html/下面,修改该目录下的HTML文件并不能使访问页面发生改变。
5、使用curl命令或者浏览器访问nginx容器和httpd容器的web页面
[root@server html]# curl 192.168.40.128:8001
sy