zoukankan      html  css  js  c++  java
  • 6、Docker Image

    6.1 什么是image

    • 文件和meta data的集合(root filesystem)
    • 分层的,并且每一层都可以添加、改变、删除文件,成为一个新的image
    • 不同的image可以共享相同的layer
    • image本身是read-only的

    Docker Images

    6.2 image的获取

    1. Build from Dockerfile
    2. Pull from Registry
    3. commit from a container's changes

    通过Dockerfile构建一个base image

    1. 编写一个c文件并编译成为可执行文件
    #include<stdio.h>
    
    int main()
    {
        printf("hello docker
    ");
    }
    
    gcc -static hello.c -o hello
    
    1. 编写Dockerfile文件
    FROM scratch
    ADD hello /
    CMD ["/hello"]
    
    1. 通过docker build构建镜像

      命令:

    docker image build <==> docker build
    
    docker build -t staryjie/hello-docker .
    
    Sending build context to Docker daemon  868.9kB
    Step 1/3 : FROM scratch
     --->
    Step 2/3 : ADD hello /
     ---> d6f5edefd7fa
    Step 3/3 : CMD ["/hello"]
     ---> Running in e1db264875b9
    Removing intermediate container e1db264875b9
     ---> 09be7d865fab
    Successfully built 09be7d865fab
    Successfully tagged staryjie/hello-docker:latest
    
    1. 通过docker history查看镜像的分层

      命令:

    docker history
    
    docker history staryjie/hello-docker:latest
    
    IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
    09be7d865fab        4 minutes ago       /bin/sh -c #(nop)  CMD ["/hello"]               0B
    d6f5edefd7fa        4 minutes ago       /bin/sh -c #(nop) ADD file:e98243ff005d26728…   865kB
    
  • 相关阅读:
    leecode-数组-27Remove Element-java
    win7未在本地计算机注册microsoft.jet.oledb.4.0+inetmgr
    VS2013+opencv2.4.9+MFC
    adb远程调试
    Service,测试
    symfony-表单学习
    Doctirne---查询更新等操作
    Doctrine2-完整创建数据库
    Doctrine2-基础概念
    twig模板基本学习
  • 原文地址:https://www.cnblogs.com/jie-fang/p/10279669.html
Copyright © 2011-2022 走看看