zoukankan      html  css  js  c++  java
  • Docker Hello-World镜像运行测试

    一、命令:docker run hello-world

        命令解释:以docker客户端命令的方式运行hello-world镜像

    命令运行结果:

     hadoop@Docker:/opt/docker$ docker run hello-world
        Unable to find image 'hello-world:latest' locally
        latest: Pulling from library/hello-world
        d1725b59e92d: Pull complete
        Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
        Status: Downloaded newer image for hello-world:latest
         
        Hello from Docker!
        This message shows that your installation appears to be working correctly.
         
        To generate this message, Docker took the following steps:
         1. The Docker client contacted the Docker daemon.
         2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
            (amd64)
         3. The Docker daemon created a new container from that image which runs the
            executable that produces the output you are currently reading.
         4. The Docker daemon streamed that output to the Docker client, which sent it
            to your terminal.
         
        To try something more ambitious, you can run an Ubuntu container with:
         $ docker run -it ubuntu bash
         
        Share images, automate workflows, and more with a free Docker ID:
         https://hub.docker.com/
         
        For more examples and ideas, visit:
    


     通过分析命令运行结果,说明docker内部的工作原理:

    (1)加载本地镜像

        # 首先在本地查找'hello-world:latest'镜像
        Unable to find image 'hello-world:latest' locally
    

     docker run一个镜像,那么则会以这个镜像作为类的模板生成一个hello-world容器实例,一个具体的对象。注意:该命令首先会查找本地的hello-world镜像。
    (2)从阿里云服务器上拉去hello-world镜像

    latest: Pulling from library/hello-world
    d1725b59e92d: Pull complete 
    Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
    Status: Downloaded newer image for hello-world:latest

    (3)、运行

        Hello from Docker!
        This message shows that your installation appears to be working correctly.
    

     (4)运行原理分析

     首先,我们在docker客户端(命令行终端窗口),执行docker命令;
    客户端回去访问我们docker所在的那台服务器主机,实质而言主机上有一个Docker daemon主线程,它会监听到客户端的docker命令,它会run容器(Container),而容器又是通过镜像生成的。如果没有hello-world容器,它就会在本地查找hello-world镜像,如果本地找到了就会直接生成一个hello-world容器,否则,会向阿里云服务器仓库拉去相应的镜像;
    从阿里云服务器仓库上拉取hello-world镜像到本地,再生成容器,进而运行。
    (5)docker容器终止运行

    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
     
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
     
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
     
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/
    

     输出这段提示以后,hello world就会停止运行,容器自动终止

    二、run到底做了什么呢?

    docker run hello-world命令运行原理图:

  • 相关阅读:
    《TCP/IP 详解 卷1:协议》第 10 章:用户数据报协议
    《TCP/IP 详解 卷1:协议》第 9 章:广播和本地组播(IGMP 和 MLD)
    在新的电脑上部署 Hexo,保留原有博客的方法
    当你不知道变量类型的完整定义时可以采取的操作
    python learning GUI
    python learning Network Programming.py
    python learning Process and Thread.py
    【2017级面向对象程序设计】第2次成绩排行
    python learning IO.py
    python learning Exception & Debug.py
  • 原文地址:https://www.cnblogs.com/zouhong/p/11761739.html
Copyright © 2011-2022 走看看