一、命令: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. 从 SOA 到微服务,企业分布式应用架构在云原生时代如何重塑?

    作者 | 易立 阿里云资深技术专家 导读:从十余年前的各种分布式系统研发到现在的容器云,从支撑原有业务到孵化各个新业务,企业的发展离不开统一的.与时俱进的技术架构.本篇文章从企业分布式应用架构层面介绍 ...

  2. Prometheus 安装Alertmanager集成

    Prometheus 安装Alertmanager集成 # 下载地址 地址1:https://prometheus.io/download/ 地址2:https://github.com/promet ...

  3. Web应急:门罗币恶意挖矿

    门罗币(Monero 或 XMR),它是一个非常注重于隐私.匿名性和不可跟踪的加密数字货币.只需在网页中配置好js脚本,打开网页就可以挖矿,是一种非常简单的挖矿方式,而通过这种恶意挖矿获取数字货币是黑 ...

  4. 《 .NET并发编程实战》阅读指南 - 第2章

    先发表生成URL以印在书里面.等书籍正式出版销售后会公开内容.

  5. 排序算法Java代码实现(四)—— 归并排序

    本篇内容: 归并排序 归并排序 算法思想: 将两个或两个以上的有序表合并成一个新的有序表, 即把待排序序列分成若干个子序列,每个子序列是有序的,然后在把有序子序列合并为整体有序序列. 此算法分为两步: ...

  6. layui 动态表格设置单元格样式

    col.push({ field: , templet: function (d) { ") { return '<span style="color:white;backg ...

  7. 用友UI层获取机构的方法

    U层: UFIDA.U9.UI.PDHelper.PDContext.Current.OrgIDPDContext.Current.OrgRef.CodeColumn

  8. loadrunner 由mdrv进程终止导致的非正常终止

    因为脚本迭代次数多的问题,迭代了3次,后来改成了迭代1次(1个Vuser),就不会了,

  9. 理解了quote和 symbol-list的 关系

    'x   ===  (quote x) '(x) ===  (list 'x)

  10. docker基础应用

    环境: centos 7  docker 19.03.0-beta3  192.168.10.10 关于如何安装docker请参考:https://www.cnblogs.com/caesar-id/ ...