一、命令: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. Helm 常用命令及操作

    Helm 常用命令 查看版本 #helm version 查看当前安装的charts #helm list 查询 charts #helm search redis 安装charts #helm in ...

  2. http & https & http/2 & SPDY & WebSocket

    参考文章: http https :https://www.jianshu.com/p/d286d097e56b https & ssl:https://www.jianshu.com/p/2 ...

  3. Scala函数式编程实现排序算法

    记得<Function Thinking>这本书中提到,现在的编程范式有两类,一类是“命令式编程”,另一类是“函数式编程”,现在我们最常使用的许多语言像c.c++.java都是命令式的,但 ...

  4. .NET Core开发的iNeuOS物联网平台部署树霉派(raspbian),从网关到云端整体解决方案。助力2019中国.NET峰会。

    2019 中国.NET 开发者峰会正式启动 目       录 1.      概述... 2 2.      树莓派硬件配置... 2 3.      软件信息... 3 4.      Raspb ...

  5. (三)golang--执行流程分析

    XXX.go--go build XXX.go--XXX.exe XXX.go--go run XXX.go 两种方式的区别:(1)如果我们先编译生成了可执行文件,那么我们可以将该可执行文件拷贝到没g ...

  6. AtomicReference示例

    对引用类型的原子性操作 /** * *对引用变量的原子操作 note: *在java中对引用类型的变量,赋值是原子性的,为什么还要有atomicReference,假如要对一个引用类型进行比较,设置等 ...

  7. 024 如何让html引用公共的头部和尾部(多个html文件公用一个header.html和footer.html)

    前端静态html页面,封装公共的头文件(header:顶部页眉,顶部导航栏等部分)和尾部文件(footer:CopyRight.友情链接等部分) 当前方法:通过load()函数,引入公共头部和尾部文件 ...

  8. 在 ubuntu 下安装 mono 和 xsp4 ,并测试

    1. 安装完 ubuntu 后,在 ubuntu 软件中查看是否自带了 mono 运行时和 XSP4,如果没有,则选中后,点击安装按钮. 2. 安装完后,在终端(类似于 Windows 上的命令行工具 ...

  9. Prometheus 编写告警规则案例

    Prometheus 编写告警规则案例 注:确保alertmanager配置完毕! 1.创建编辑文件:vim /usr/local/prometheus/rules/node.yml # groups ...

  10. 用pyenv管理Python多版本及下载加速方法--Mac上

    原文:https://www.jianshu.com/p/91fc7ecc5e46 先大致介绍下pyenv的安装及配置流程.随后介绍加速下载方法 安装: brew install pyenv 配置 在 ...