项目2:搭建打飞机小游戏,验证数据持久化(最底下有链接)
第一步:拉取镜像
[root@localhost docker-image]# docker load < httpd_img.tar.gz
[root@localhost /]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest fb2f3851a971 18 months ago 178MB
tomcat test a29e200a18e9 3 years ago 358M
第二部:启动镜像
[root@localhost /]# docker run -d --name httpd -p 82:80 -v /game:/usr/local/apache2/htdocs httpd
85e34ea6559ed6a63e1b35c65002e3453fd65d2bf522c7d91244864c506f3553
第三步:把网站数据放到/game目录之下
[root@localhost /]# cp /game.zip /game
[root@localhost ~]# cp /game/game/* /game/ -a
第四步:浏览器访问
IP:PORT/sky_fight.html
第五步:验证数据持久化:
删掉容器
[root@localhost game]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85e34ea6559e httpd "httpd-foreground" 17 minutes ago Up 17 minutes 0.0.0.0:82->80/tcp httpd
9225fd6da0e2 tomcat:test "catalina.sh run" 47 minutes ago Up 47 minutes 0.0.0.0:86->8080/tcp tomcat
[root@localhost game]# docker rm -f 85e34ea6559e
85e34ea6559e
[root@localhost game]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9225fd6da0e2 tomcat:test "catalina.sh run" 48 minutes ago Up 48 minutes 0.0.0.0:86->8080/tcp tomcat
再次启动容器
[root@localhost game]# docker run -d --name httpd -p 82:80 -v /game:/usr/local/apache2/htdocs httpd
391afba79c84f38bdfe1d53a3a53976f8e98f1cddabdea7520f40d73544de8ab
浏览器验证:
快来挑战吧!!!
game.zip
链接:https://pan.baidu.com/s/1LdWT6_VnxcSkPlnYWWDf9Q
提取码:d7vu
复制这段内容后打开百度网盘手机App,操作更方便哦
httpd_img.tar.gz
链接:https://pan.baidu.com/s/1cDOmGdMv0VC3KZfSErXq0w
提取码:ryvl
复制这段内容后打开百度网盘手机App,操作更方便哦