• 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 ~]# 
    
  • 相关阅读:
    016 vue的组件通信
    015 vue组件中的数据
    014 vue的组件化开发
    013 vue的js中的高阶函数
    012 vue的v-model的使用
    011 vue的购书案例
    010 vue的过滤器的使用
    CF1519F
    CF1519E
    CF1517F
  • 原文地址:https://www.cnblogs.com/jie-fang/p/10279685.html
Copyright © 2020-2023  润新知