dockerfile实战
1:dockerfile部署扫雷案例
1、所需软件包和环境
Centos-7.repo epel-7.repo saolei.zip
server1:部署docker扫雷案例
server2:部署apache,将saolei.zip软件包上传上去
2、编辑Dockerfile,使用基础镜像centos:7
3、构建镜像saolei:v1
4、运行容器,指定映射端口8081:8080
5、使用浏览器访问http://自己docker服务器的ip/saolei.jsp,能够实现扫雷游戏的使用
首先在server2上部署apache,并将saolei.zip软件包上传去如下
[root@localhost ~]# hostnamectl set-hostname server2
[root@localhost ~]# bash
[root@server2 ~]# yum -y install httpd //部署apache服务
Installed:
httpd.x86_64 0:2.4.6-97.el7.centos.5
Dependency Installed:
apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7
httpd-tools.x86_64 0:2.4.6-97.el7.centos.5 mailcap.noarch 0:2.1.41-2.el7
Complete!
[root@server2 ~]# cd /var/www/html/
[root@server2 html]# ls //将软件包上传上去
saolei.zip
[root@server2 ~]# systemctl enable --now httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@server2 html]# systemctl restart httpd.service
[root@server2 html]# systemctl stop firewalld.service
[root@server2 html]# vim /etc/selinux/config //关闭selinux
[root@server2 html]# setenforce 0
server1编辑Dockerfile,使用基础镜像centos:7
[root@server1 ~]# mkdir dd
[root@server1 ~]# cd dd
[root@server1 d