一、命令: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命令运行原理图:

Docker Hello-World镜像运行测试的更多相关文章

  1. Docker的ubuntu镜像安装的容器无ifconfig和ping命令的解决

    Docker的Ubuntu镜像安装的容器无ifconfig命令和ping命令 解决: apt-get update apt install net-tools       # ifconfig apt ...

  2. 关于Docker官方CentOS镜像无法启动mysqld的总结

    很多童鞋反映,在Docker官方CentOS镜像中安装了Mysql server后,无法正常启动. 无法正常启动表现为两种情况: 1> 初始完数据库后,mysqld启动报错 2> syst ...

  3. 理解docker容器和镜像(layer,ufs)和docker命令解释

    博客好文1:http://blog.csdn.net/x931100537/article/details/49633107(理解docker容器和镜像,理解简单,从原理入手,什么是layer,什么是 ...

  4. 4.docker学习之镜像

    镜像 我们知道,我们想在Windows操作系统上跑Linux,需要安装一个虚拟机程序,然后下载一个Linux镜像,在该虚拟机程序中创建一个虚拟机,并使用该镜像安装对应的Linux操作系统,安装好之后, ...

  5. 容器与Docker简介(四)Docker容器,镜像与 Registries——微软微服务电子书翻译系列

    当使用Docker时,开发人员创建一个应用程序或服务,并将其和其依赖关系打包到容器镜像中. 镜像是应用程序或服务及其配置和依赖的静态表示形式. 要运行应用程序或服务,应用程序的镜像将被实例化以创建一个 ...

  6. docker之NGINX镜像构建

    Nginx是一个高性能的Web和反向代理服务器,它具有很多非常优越的特性:1.作为Web服务器.2.作为负载均衡服务器.3.作为邮件代理服务器.4.安装及配置简单.接下来我们介绍在docker构建ng ...

  7. Docker 中国官方镜像加速

    参考:https://www.docker-cn.com/registry-mirror 通过 Docker 官方镜像加速,中国区用户能够快速访问最流行的 Docker 镜像.该镜像托管于中国大陆,本 ...

  8. Docker公共&本地镜像仓库(七)--技术流ken

    分发镜像 我们已经会构建自己的镜像了,那么如果在多个docker主机上使用镜像那?有如下的几种可用的方法: 用相同的Dockerfile在其他host上构建镜像 将镜像上传到公共registry(比如 ...

  9. docker简单介绍----镜像和容器管理

    docker可以分为三部分:docker镜像   docker仓库  docker容器 docker镜像:一个image可以包含一个镜像,也可以理解为一个系统模板,里面安装了相关应用,也可以是纯净版的 ...

随机推荐

  1. Centos7.5 安装Mysql5.7

    #yum -y install wget #wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rp ...

  2. Spring Boot 自定义 Shiro 过滤器,无法使用 @Autowired 解决方法

    在 Spring Boot 中集成 Shiro,并使用 JWT 进行接口认证. 为了统一对 Token 进行过滤,所以自定义了一个 JwtTokenFilter 过滤器. 期间遇到了以下几个问题,这里 ...

  3. MYSQL LIMIT 性能测试

    查询语句 # 普通表 SELECT * FROM test_page LIMIT m,n # 内存表 SELECT * FROM test_page_memory LIMIT m,n 总结 查询位置( ...

  4. Windbg断点调试.net程序

    程序员都知道,在生产环境中,如果没有系统日志,对问题的分析将非常的困难.即使有日志,有时候也会因为日志记录的不全面,而导致问题不能分析清楚.其实,Windbg里面有Live Debug功能,正好可以借 ...

  5. sizeof()计算结构体的大小

    简要说明:结构体成员按照定义时的顺序依次存储在连续的内存空间,但是结构体的大小并不是简单的把所有成员大小相加,而是遵循一定的规则,需要考虑到系统在存储结构体变量时的地址对齐问题. 一.没有成员的结构体 ...

  6. java中需要转义的特殊字符

    在Java中,不管是String.split(),还是正则表达式,有一些特殊字符需要转义, 这些字符是 (    [     {    /    ^    -    $     ¦    }    ] ...

  7. WPF DataGrid横向显示

    前言 利用各种变换,将其水平改向至横向显示. 注意的是要固定好单元格的高宽,或者手动编写style 否者在滚动的时候,会有高宽比例不一样的时候 再其次,要注意datagrid的容器或者datagrid ...

  8. Blackbox_exporter黑盒监测

    一.概述 blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http.dns.tcp.icmp 的监控数据采集.Blackbox_exporter ...

  9. vscode 代码折叠快捷键,折叠所有/展开所有

    1.折叠所有区域的快捷键:ctrl + k   ctrl + 0 (这里是数字键0) 2.展开所有区域的快捷键:ctrl + j    ctrl + j

  10. ORA-03113: 通信通道的文件结束解决方法一例

    开发项目时,使用的是Oracle数据库.最近遇到了“ORA-03113: 通信通道的文件结束”错误.如下图所示: 经过网上查资料和请教同事,终于找到了解决ORA-03113错误的办法. 解决步骤如下: ...