赞
踩
在前面的《Centos7中安装及验证Docker》和《Windows8中安装及验证Docker》两篇文章中都有看到:docker run hello-word
,为了更深入的认识Docker,在这篇文章中着重讲解一下这句命令的作用和工作流程,从而更加深刻的认识Docker的工作原理。
docker run hello-word
将会出现:
C:\Users\zsl-pc>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
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.
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 Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
说明:
Unable to find image 'hello-world:latest' locally
:表示没有在本地找到镜像hello-world:latest
:latest
:是指版本号或标记,同一个应用程序可能有多个版本或多个标记,我们可以通过修改latest
来修改对应的版本信息。
latest: Pulling from library/hello-world
:正在拉取镜像,也就是将该镜像下载到本地
c04b14da8d14: Pull complete
:下载完成。
从Hello from Docker!
开始到最后就是hello-world
这个镜像所做的工作,它只是输出了这样几句话。
当再次输入:docker run hello-world
时,将不再出现类似Unable to find image 'hello-world:latest' locally
和pulling
的字样,因为该镜像已经在本地存在,只需要直接run就行。
C:\Users\zsl-pc>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest c54a2cc56cbb 4 months ago 1.848 kB
在这里可以看到这些镜像的仓库、标记、id、创建时间、大小等信息
C:\Users\zsl-pc>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
fcee30d727b4 hello-world "/hello" 14 minutes ago Exited (0) 13 minutes ago
elated_feynman
e2eb5d0a9f96 hello-world "/hello" 18 minutes ago Exited (0) 16 minutes ago
cranky_engelbart
在这里可以看到所有已经运行(过)的容器,包括:容器Id、对应镜像、命令行、创建时间、状态、端口号和名称。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。