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

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

问题描述

我想了解使用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。

Command used to build the image: 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中的每条指令( RUN COPY 等)执行以下操作:

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. 将临时容器另存为新的图像层。 / li>
  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天全站免登陆