中间容器是如何形成的? [英] How are intermediate containers formed?

查看:9
本文介绍了中间容器是如何形成的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解使用 Dockerfile 构建 Docker 映像所涉及的执行步骤.我在下面列出了几个问题.请帮助我了解构建过程.

I would like to understand the execution steps involved in building Docker Images using Dockerfile. Couple of questions I have listed down below. Please help me in understanding the build process.

#from base image
FROM ubuntu:14.04
#author name
MAINTAINER RAGHU
#commands to run in the container
RUN echo "hello Raghu"
RUN sleep 10
RUN echo "TASK COMPLETED"

用于构建镜像的命令:docker build -t raghavendar/hands-on:2.0 .

Sending build context to Docker daemon 20.04 MB
Step 1 : FROM ubuntu:14.04
---> b1719e1db756
Step 2 : MAINTAINER RAGHU
---> Running in 532ed79e6d55
---> ea6184bb8ef5
Removing intermediate container 532ed79e6d55
Step 3 : RUN echo "hello Raghu"
---> Running in da327c9b871a
hello Raghu
---> f02ff92252e2
Removing intermediate container da327c9b871a
Step 4 : RUN sleep 10
---> Running in aa58dea59595
---> fe9e9648e969
Removing intermediate container aa58dea59595
Step 5 : RUN echo "TASK COMPLETED"
---> Running in 612adda45c52
TASK COMPLETED
---> 86c73954ea96
Removing intermediate container 612adda45c52
Successfully built 86c73954ea96

在第 2 步中:

Step 2 : MAINTAINER RAGHU
    ---> Running in 532ed79e6d55 

问题1:表示它运行在id为532ed79e6d55的容器中,但是这个容器是用什么Docker镜像形成的?

Question 1 : it indicates that it is running in the container with id - 532ed79e6d55, but with what Docker image is this container formed ?

---> ea6184bb8ef5  

问题 2:这个 id 是什么?它是图像还是容器?

Question 2 : what is this id? Is it an image or container ?

Removing intermediate container 532ed79e6d55

问题3:最终的图像是由中间容器保存的多层形成的吗?

Question 3 : Is the final image formed with multiple layers saved from intermediate containers?

推荐答案

是的,Docker 镜像是分层的.当你构建一个新镜像时,Docker 会为 Dockerfile 中的每条指令(RUNCOPY 等)执行此操作:

Yes, Docker images are layered. When you build a new image, Docker does this for each instruction (RUN, COPY etc.) in your Dockerfile:

  1. 从前一个图像层(或第一个命令的基本 FROM 图像)创建一个临时容器;
  2. 在临时中间"容器中运行 Dockerfile 指令;
  3. 将临时容器保存为新的图像层.
  1. create a temporary container from the previous image layer (or the base FROM image for the first command;
  2. run the Dockerfile instruction in the temporary "intermediate" container;
  3. save the temporary container as a new image layer.

最终的镜像层被标记为任何你命名的镜像 - 如果你运行 docker history raghavendar/hands-on:2.0 就会清楚,你会看到每一层和一个缩写创建它的指令.

The final image layer is tagged with whatever you name the image - this will be clear if you run docker history raghavendar/hands-on:2.0, you'll see each layer and an abbreviation of the instruction that created it.

您的具体查询:

1) 532 是从镜像 ID b17 创建的临时容器,也就是你的 FROM 镜像 ubuntu:14.04.

1) 532 is a temporary container created from image ID b17, which is your FROM image, ubuntu:14.04.

2) ea6 是作为指令输出创建的图像层,即来自保存中间容器532.

2) ea6 is the image layer created as the output of the instruction, i.e. from saving intermediate container 532.

3) 是的.Docker 将此称为 联合文件系统,它是主要的图像如此高效的原因.

3) yes. Docker calls this the Union File System and it's the main reason why images are so efficient.

这篇关于中间容器是如何形成的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆