0
点赞
收藏
分享

微信扫一扫

使用dockerfile创建httpd镜像

谁知我新 2023-11-08 阅读 58

 一、新建文件夹,用于专门存放dockerfile文件,并进入该文件夹

mkdir /root/dockerfile/httpd -p ;cd /root/dockerfile/httpd

  二、下载centos:7镜像

docker pull centos:7

  三、编辑测试页面

vim index.html 

  test page

  三、编辑dockerfile文件

vim  dockerfile

FROM centos:7
RUN yum install httpd -y
EXPOSE 80
COPY index.html /usr/share/httpd/noindex/index.html
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]

##   开头字段必须大写

##   FROM centos:7,使用centos:7 镜像

##   RUM yum install httpd -y ,执行的安装命令

##   EXPOSE 80, 声明端口

##   COPY index.html /usr/share/httpd/noinde/index.html,拷贝网页文件

##   CMD["/usr/sbin/httpd","-D","FOREGROUND"],前台执行命令

  四、构建镜像

docker build -t httpd:v66 .

##  v66是标签名

  五、查看ID

docker images

  六、创建容器

docker run -itd -p 66:80 f3e5bafcdba6

##  f3e5bafcdba6,image id  通过docker ps获取

  七、测试访问

http://192.168.1.9:66/

举报

相关推荐

0 条评论