在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。
因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。
什么是容器?
在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。
因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。
什么是容器?
当前回答
映像是构建容器(正在运行的实例)的蓝图。
其他回答
Image相当于OOP中的类定义,层是该类的不同方法和属性。
容器是图像的实际实例化,就像对象是实例化或类的实例一样。
I would like to fill the missing part here between docker images and containers. Docker uses a union file system (UFS) for containers, which allows multiple filesystems to be mounted in a hierarchy and to appear as a single filesystem. The filesystem from the image has been mounted as a read-only layer, and any changes to the running container are made to a read-write layer mounted on top of this. Because of this, Docker only has to look at the topmost read-write layer to find the changes made to the running system.
我想用以下类比来说明:
+-----------------------------+-------+-----------+
| Domain | Meta | Concrete |
+-----------------------------+-------+-----------+
| Docker | Image | Container |
| Object oriented programming | Class | Object |
+-----------------------------+-------+-----------+
长话短说。
码头工人图片:
用于创建容器的文件系统和配置(只读)应用程序。
码头工人的容器:
容器和映像之间的主要区别是最上面的可写层。容器是顶层可写层的Docker映像的运行实例。容器运行实际的应用程序。容器包括应用程序及其所有依赖项。当容器被删除时,可写层也会被删除。底层图像保持不变。
其他需要注意的重要术语:
码头工人守护进程:
运行在主机上的后台服务,它管理构建,运行和分发Docker容器。
码头工人客户:
允许用户与Docker守护进程交互的命令行工具。
码头工人商店:
Store是一个Docker映像的注册表。您可以将注册表视为所有可用Docker映像的目录
这篇博文中的一张图片胜过千言万语。
简介:
从Docker中心提取图像或从Dockerfile构建=>给出一个 Docker图像(不可编辑)。 运行image (docker Run image_name:tag_name) =>给出一个运行 图片即容器(可编辑)
在编程方面,
图片是源代码。
当编译和构建源代码时,它被称为应用程序。
类似于“当为映像创建实例时”,它被称为“容器”。