zoukankan      html  css  js  c++  java
  • 使用dockerfile创建httpd镜像

      案例1 使用dockerfile创建并启动一个httpd镜像

      一、新建文件夹,用于专门存放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/

    ---------------------------------------------------------------------------------------------------------------------------------

       

    ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------- 博客均为个人笔记,无所追求,仅供参考~~~ QQ--2382990774
  • 相关阅读:
    1052 Linked List Sorting (25 分)
    1051 Pop Sequence (25 分)
    1050 String Subtraction (20 分)
    1049 Counting Ones (30 分)
    1048 Find Coins (25 分)
    1047 Student List for Course (25 分)
    1046 Shortest Distance (20 分)
    1045 Favorite Color Stripe (30 分)
    1044 Shopping in Mars (25 分)
    1055 The World's Richest (25 分)
  • 原文地址:https://www.cnblogs.com/alexlv/p/15498571.html
Copyright © 2011-2022 走看看