1、画出docker command的思维导图
2、运行一个nginx的容器,要求如下:将容器的80端口映射到宿主机的8000端口,并将数据卷my-volume挂载到/usr/share/nginx/html目录
docker run --name web1 -d -p 8000:80 nginx -v my-volume:/usr/share/nginx/html
3、运行一个httpd的容器,要求如下:将容器的80端口映射到宿主机的8001端口,并将数据库my-volume挂载到/var/www/html
docker run --name web2 -d -p 8001:80 httpd -v my-volume:/var/www/html
4、进入容器httpd,修改/var/www/html/index.html文件的内容为welcome to httpd
[root@centos7 ~]# docker exec -it httpd /bin/sh
# find / -name index.html #在httpd容器中找index.html文件并修改其内容
find: '/proc/1/map_files': Operation not permitted
find: '/proc/8/map_files': Operation not permitted
find: '/proc/9/map_files': Operation not permitted
find: '/proc/10/map_files': Operation not permitted
find: '/proc/92/map_files': Operation not permitted
find: '/proc/100/map_files': Operation not permitted
/usr/local/apache2/htdocs/index.html
# echo welcome to httpd > /usr/local/apache2/htdocs/index.html
# cat /usr/local/apache2/htdocs/index.html
welcome to httpd
[root@contos7 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3518f9e63170 httpd "httpd-foreground" 17 minutes ago Up 5 minutes 0.0.0.0:8001->80/tcp, :::8001->80/tcp httpd
038aedbbe80a nginx:1.14-alpine "nginx -g 'daemon of…" 2 hours ago Up 4 seconds 0.0.0.0:8000->80/tcp, :::8000->80/tcp web
5、使用curl命令或者浏览器访问nginx容器和httpd容器的web页面
[root@centos7 ~]# hostname -I #查看宿主机及容器的ip地址
192.168.15.133 172.17.0.1
[root@centos7 ~]# curl 172.17.0.1:8000 #访问ngnix容器的web页面
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
#访问nginx容器的web页面
[root@centos7 ~]# curl 172.17.0.1:8001
welcome to httpd