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 ~]# 
    
  • 相关阅读:
    POJ 1094 (传递闭包 + 拓扑排序)
    POJ 2594 (传递闭包 + 最小路径覆盖)
    POJ 3041 Asteroids(二分图最大匹配)
    差分数组原理与其前缀和的应用
    树状数组的理解以及简单应用
    HDU 4635 (完全图 和 有向图缩点)
    2.基本数据类型
    Python基础
    数据库类型
    Vue-2
  • 原文地址:https://www.cnblogs.com/jie-fang/p/10279685.html
Copyright © 2011-2022 走看看