zoukankan      html  css  js  c++  java
  • 项目——基于httpd镜像演示Dockerfile所有的指令


    基于httpd镜像演示Dockerfile所有的指令:

    第一步:创建Dockerfile工作目录

    [root@localhost harbor]# mkdir /test
    [root@localhost harbor]# cd /test/
    [root@localhost test]# echo 11111 > 1.txt
    [root@localhost test]# ls
    1.txt 
    [root@localhost test]# vim Dockerfile
    FROM httpd:latest
    LABEL author=wuxun
    ENV dir=/usr/local/apache2/htdocs
    WORKDIR $dir
    COPY 1.txt ./
    RUN touch {1..3}.txt
    ADD https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/adwaita-qt-common-1.0-1.el7.x86_64.rpm ./
    EXPOSE 80 3306
    VOLUME $dir
    CMD ["httpd-foreground"] 

    第二步:基于dockerfile创建镜像

    [root@localhost test]# docker build -t httpd:test1
    "docker build" requires exactly 1 argument.
    See 'docker build --help'.
    Usage: docker build [OPTIONS] PATH | URL | -
    Build an image from a Dockerfile
    [root@localhost test]# docker build -t httpd:test1 ./
    Sending build context to Docker daemon 3.072kB
    Step 1/10 : FROM httpd:latest
    ---> fb2f3851a971
    ...
    Successfully built 8b0d23d4e733
    Successfully tagged httpd:test1
    [root@localhost test]# docker image ls
    REPOSITORY TAG IMAGE ID CREATED SIZE
    httpd test1 8b0d23d4e733 3 minutes ago 178MB

    第三步:基于新创建的镜像启动容器

    [root@localhost test]# docker run -d httpd:test1
    5b6975fd8ad966bd8359ebe0538bd22cb0c9f43d2d6d98c64e806bef93f32e88
    [root@localhost test]# docker ps
    CONTAINER ID        IMAGE                                               COMMAND                  CREATED             STATUS                 PORTS                       NAMES
    5b6975fd8ad9        httpd:test1                                         "httpd-foreground"       18 seconds ago      Up 17 seconds          80/tcp, 3306/tcp            jolly_gagarin
    

    第四步:验证  

    [root@localhost test]# docker exec -it 5b6975fd8ad9 bash
    root@5b6975fd8ad9:/usr/local/apache2/htdocs# ls
    1.txt  adwaita-qt-common-1.0-1.el7.x86_64.rpm  index.html  {1..3}.txt
    root@5b6975fd8ad9:/usr/local/apache2/htdocs# exit
    exit
    [root@localhost test]# docker image ls |grep httpd
    httpd                           test1                      8b0d23d4e733        31 minutes ago      178MB
    192.168.59.200/test/httpd       v1                         fb2f3851a971        18 months ago       178MB
    httpd                           latest                     fb2f3851a971        18 months ago       178MB
    [root@localhost test]# docker ps | grep httpd
    5b6975fd8ad9        httpd:test1                                         "httpd-foreground"       26 minutes ago      Up 26 minutes          80/tcp, 3306/tcp            jolly_gagarin
    

      

  • 相关阅读:
    [JSOI2007][BZOJ1030] 文本生成器|AC自动机|动态规划
    [NOI2014][BZOJ3670] 动物园|KMP
    [HAOI2010][BZOJ2427] 软件安装|tarjan|树型dp
    [JSOI2008][BZOJ1017] 魔兽地图DotR|树型dp
    [JLOI2014][BZOJ3631] 松鼠的新家|树上倍增LCA|差分
    [SDOI2010][BZOJ1975] 魔法猪学院|A*|K短路
    [BZOJ1251] 序列终结者|Splay
    hdu 2141 Can you find it?
    hdu 3152 Obstacle Course
    hdu 2680 Choose the best route
  • 原文地址:https://www.cnblogs.com/twoo/p/11822384.html
Copyright © 2011-2022 走看看