docker启动示范”hello world”

这个镜像很好说明了docker启动的完整过程,注意看对应的输出日志

[[email protected] ~]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
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/

[[email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5fb08267227e ubuntu:14.04 "/bin/bash" 13 minutes ago Up 13 minutes ubuntu_4
be9d5c6f2a25 ubuntu:14.04 "/bin/bash" 21 minutes ago Up 21 minutes ubuntu_3
dca3d42e5e3e ubuntu:14.04 "/bin/bash" 30 minutes ago Exited (0) 18 minutes ago ubuntu_2
7103a04f97d3 ubuntu:14.04 "/bin/bash" 3 hours ago Up 3 hours ubuntu
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 2c5e00d77a67 7 weeks ago 188MB
hello-world latest fce289e99eb9 6 months ago 1.84kB

我稍微翻译一下:

1、客户端联系守护进程

2、守护进程拉取hello world镜像

3、守护进程创建一个容器用来运行这个hello world镜像

4、守护进程以流的方式把运行结果输出到屏幕

然后对照events看看是不是这个过程

2019-07-04T22:33:40.618342042+08:00 image pull hello-world:latest (name=hello-world)
2019-07-04T22:33:40.659685188+08:00 container create 2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a (image=hello-world, name=hungry_heyrovsky)
2019-07-04T22:33:40.665818350+08:00 container attach 2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a (image=hello-world, name=hungry_heyrovsky)
2019-07-04T22:33:40.693804970+08:00 network connect 05475ea368337254dea611bfff0a86005befb5ea3da6e3bb6b7b3d40bbe4e33e (container=2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a, name=bridge, type=bridge)
2019-07-04T22:33:41.041510163+08:00 container start 2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a (image=hello-world, name=hungry_heyrovsky)
2019-07-04T22:33:41.141978025+08:00 container die 2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a (exitCode=0, image=hello-world, name=hungry_heyrovsky)
2019-07-04T22:33:41.193071966+08:00 network disconnect 05475ea368337254dea611bfff0a86005befb5ea3da6e3bb6b7b3d40bbe4e33e (container=2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a, name=bridge, type=bridge)
2019-07-04T22:33:41.218441072+08:00 container destroy 2c90659a7339842a569defd05ff5a7dee65d7a4d46383045b284a33fff1e8c3a (image=hello-world, name=hungry_heyrovsky)
此条目发表在Docker分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注