zoukankan      html  css  js  c++  java
  • 8、创建镜像

    8.1 通过Container创建镜像

      命令:

    docker container commit <==> docker commit
    
    [root@docker ~]# docker run -it centos
    
    [root@41fec031cde0 /]# yum install -y vim
    [root@41fec031cde0 /]# exit
    exit
    [root@docker ~]# docker container -aq   #获取容器的ID
    41fec031cde0
    [root@docker ~]# docker commit 41fec031cde0 staryjie/centos-vim
    sha256:7f25650f744f3a9e72e6d7fce30841f32fb15103b54e97863f289e7c75cd1f29
    [root@docker ~]# docker images
    REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
    staryjie/centos-vim     latest              7f25650f744f        34 seconds ago      324MB
    staryjie/hello-docker   latest              09be7d865fab        About an hour ago   865kB
    ubuntu                  14.04               8cef1fa16c77        4 weeks ago         223MB
    ubuntu                  latest              452a96d81c30        4 weeks ago         79.6MB
    hello-world             latest              e38bc07ac18e        7 weeks ago         1.85kB
    centos                  latest              e934aafc2206        7 weeks ago         199MB
    

    8.2 通过Dockerfile创建镜像

      命令:

    docker image build <==> docker build
    

      编写Dockerfile:

    FROM centos
    RUN yum install -y vim
    

      构建镜像:

    [root@docker ~]# docker build -t staryjie/centos-vim-new .
    
    Sending build context to Docker daemon  2.048kB
    Step 1/2 : FROM centos
     ---> e934aafc2206
    Step 2/2 : RUN yum install -y vim
     ---> Running in c96490b78363   #构建是临时创建的container的ID
     Removing intermediate container c96490b78363
     ---> b717d7ce6840
    Successfully built b717d7ce6840
    Successfully tagged staryjie/centos-vim-new:latest
    [root@docker ~]# docker images
    REPOSITORY                TAG                 IMAGE ID            CREATED              SIZE
    staryjie/centos-vim-new   latest              b717d7ce6840        About a minute ago   324MB
    staryjie/centos-vim       latest              7f25650f744f        10 minutes ago       324MB
    staryjie/hello-docker     latest              09be7d865fab        About an hour ago    865kB
    ubuntu                    14.04               8cef1fa16c77        4 weeks ago          223MB
    ubuntu                    latest              452a96d81c30        4 weeks ago          79.6MB
    hello-world               latest              e38bc07ac18e        7 weeks ago          1.85kB
    centos                    latest              e934aafc2206        7 weeks ago          199MB
    [root@docker ~]# 
    
  • 相关阅读:
    实现用户注册验证码
    自带的打印预览
    分页存储过程
    文章标题、内容、摘要的处理函数
    ASP常用函数收藏
    生活中的经典感人语句
    如何在某一数据库的所有表的所有列上搜索一个字符串?
    如何访问隐藏的列表 workflow history list
    Windows Server 2008下如果什么操作没能正常完成, 请尝试run as administrator
    Visual Studio Build Marcos
  • 原文地址:https://www.cnblogs.com/jie-fang/p/10279685.html
Copyright © 2011-2022 走看看