Docker----Docker容器的启动流程

DevOps技术社区 2022-08-27 15:49:32

目录

  • (1)首先确认本机没有 hello-world 镜像
  • (2)然后执行docker run hello-world 运行hello-world容器,回显如下
  • (3)docker容器的启动流程如下
  • (4)第二次执行docker run hello-world运行容器

(1)首先确认本机没有 hello-world 镜像

[root@redrose2100 ~]# docker images | grep hello-world
[root@redrose2100 ~]#

(2)然后执行docker run hello-world 运行hello-world容器,回显如下

[root@redrose2100 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
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:
 https://docs.docker.com/get-started/

[root@redrose2100 ~]#

(3)docker容器的启动流程如下

image.png

  • (1)执行docker run hello-world命令后,docker命令会在本机寻找名为hello-world的镜像,比如这里发现本地没有
  • (2)此时docker 就会去docker hub上搜索名称为hello-world的镜像,比如这里在docker hub上搜索到了hello-world的镜像
  • (3)从docker hub上下载名称为hello-world的镜像到本地
  • (4)使用hello-world镜像执行此docker

(4)第二次执行docker run hello-world运行容器

[root@redrose2100 ~]# docker run hello-world

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:
 https://docs.docker.com/get-started/

[root@redrose2100 ~]#

可以发现此时,会使用本地已经存在的镜像。而不会再去docker hub 上下载镜像了

...全文
1931 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

32

社区成员

发帖
与我相关
我的任务
社区描述
围绕测试开发、Devops、软件工程等方向,学习交流,共享技术新动态、新方向。求助工作中的问题,困惑等,互相交流,共同成长
软件工程测试工具devops 技术论坛(原bbs) 江苏省·南京市
社区管理员
  • redrose2100
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

1、社区话题和文章主要围绕DevOps技术栈

2、有广告需求请联系微信 Redrose2100

 

试试用AI创作助手写篇文章吧