[英]DockerFile: Is it use to create an image or To the docker host how to create the container
I am confused with some terms. 我对某些术语感到困惑。
Is Dockerile
designed to create an image or a set of instruction of how to create a container from an image? Dockerile
是设计用来创建映像还是用于从映像创建容器的一组指令?
Because there are command eg FROM
(to get the base image), RUN
(To run executable in the container) etc. These command looks like an instruction to how to create the container. 因为有命令,例如
FROM
(获取基本映像), RUN
(在容器中运行可执行文件)等。这些命令看起来像是有关如何创建容器的指令。
Docker images are static, and are built from the instructions specified in the Dockerfile
. Docker映像是静态的,并且是根据
Dockerfile
指定的指令Dockerfile
。 They use Union File-System (UnionFS), so that the changes made when building an image are stacked on top of each other, generating a DAG (Directed Acyclic Graph) of build history. 他们使用联合文件系统(UnionFS),以便在构建映像时所做的更改彼此堆叠,从而生成构建历史记录的DAG(有向无环图)。 The
FROM
directive at the top of the Dockerfile
simply points to an existing image, and starts building on top of that. Dockerfile
顶部的FROM
指令仅指向现有映像,并在此映像之上开始构建。
A container is simply an instantiated version of an image, basically just this UnionFS with a read/write layer dropped on top of it. 容器只是图像的实例化版本,基本上就是这个UnionFS,在其顶部放置了一个读/写层。
Interestingly, if you watch the output when you run docker build
(in a directory with a Dockerfile
) you'll see that what is happening is each instruction starts up a container based on the current state of the image, runs the command ( apt-get install ...
or whatever) and then commit
s that change to the image. 有趣的是,如果您在运行
Dockerfile
docker build
(在带有Dockerfile
的目录中)观察输出,您会发现正在发生的事情是每条指令根据映像的当前状态启动一个容器,然后运行命令( apt-get install ...
或其他内容),然后commit
更改为映像的。 That's why it's good to batch up commands in a Dockerfile
- because each one will start a new container. 这就是在
Dockerfile
批处理命令的好Dockerfile
-因为每个命令都会启动一个新容器。
Dockerfile is used to create an image which you can later use to create a container using docker build
. Dockerfile被用于创建以后可以使用它来创建使用容器的图像
docker build
。
From the docs 来自文档
Docker can build images automatically by reading the instructions from a Dockerfile.
Docker可以通过阅读Dockerfile中的指令来自动构建映像。 A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
Dockerfile是一个文本文档,其中包含用户可以在命令行上调用以组装映像的所有命令。 Using docker build users can create an automated build that executes several command-line instructions in succession.
使用docker build的用户可以创建自动执行的构建,该构建可以连续执行几个命令行指令。
Also RUN
will instruction will execute any commands in a new layer on top of the current image and commit the results . 同样,
RUN
will指令将在当前图像顶部的新层中执行任何命令并提交结果 。 The resulting committed image will be used for the next step in the Dockerfile
and not "Run (To run executable in the container)". 生成的提交映像将用于
Dockerfile
中的Dockerfile
而不是“运行(在容器中运行可执行文件)”。 For details see this . 有关详情请参阅本 。
Image: Docker engine
use Dockerfile
reference to build up Image
from Dockerfile
instruction like (FROM, RUN etc.) 图像:
Docker engine
使用Dockerfile
引用从Dockerfile
指令(例如FROM,RUN等)构建Image
Container: Docker engine
start container from Image
and we can say Container
is RUN time instance of Image
容器:
Docker engine
从Image
启动容器,我们可以说Container
是Image
运行时间实例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.