在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。
因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。
什么是容器?
在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。
因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。
什么是容器?
当前回答
映像是构建容器(正在运行的实例)的蓝图。
其他回答
映像或容器映像是一个包含应用程序代码、应用程序运行时、配置和依赖库的文件。映像基本上是将所有这些包装成一个单一的、安全的不可变单元。使用适当的docker命令构建映像。图像有图像id和图像标签。标签的格式通常为<docker-user-name>/image-name:tag。
当您开始使用映像运行应用程序时,实际上是启动了一个容器。你的容器是一个运行图像的沙盒。Docker软件用于管理映像和容器。
Image是一个安全的包,其中包含应用程序工件、库、配置和应用程序运行时。容器是映像的运行时表示形式。
对于一个虚拟的编程类比,你可以认为Docker有一个抽象的ImageFactory,它保存着它们来自存储的ImageFactory。
然后,一旦你想从ImageFactory中创建一个应用程序,你就有了一个新的容器,你可以随心所欲地修改它。DotNetImageFactory将是不可变的,因为它作为一个抽象工厂类,在那里它只交付您想要的实例。
IContainer newDotNetApp = ImageFactory.DotNetImageFactory.CreateNew(appOptions);
newDotNetApp.ChangeDescription("I am making changes on this instance");
newDotNetApp.Run();
简而言之:
容器是内核中的一个分区(虚拟),它共享一个公共操作系统并运行一个镜像(Docker镜像)。
容器是一个自我维持的应用程序,它将包含包和运行代码所需的所有依赖项。
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.
在编程方面,
图片是源代码。
当编译和构建源代码时,它被称为应用程序。
类似于“当为映像创建实例时”,它被称为“容器”。