在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。

因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。

什么是容器?


当前回答

Docker的核心概念是使创建“机器”变得容易,在这种情况下,机器可以被认为是容器。容器有助于重用性,允许您轻松地创建和删除容器。

图像描述了容器在每个时间点上的状态。所以基本的工作流程是:

创建映像 启动容器 对容器进行更改 将容器重新保存为图像

其他回答

就像对象是面向对象编程语言中类的实例一样,Docker容器也是Docker映像的实例。

虽然将容器看作一个运行的映像是最简单的,但这并不十分准确。

An image is really a template that can be turned into a container. To turn an image into a container, the Docker engine takes the image, adds a read-write filesystem on top and initialises various settings including network ports, container name, ID and resource limits. A running container has a currently executing process, but a container can also be stopped (or exited in Docker's terminology). An exited container is not the same as an image, as it can be restarted and will retain its settings and any filesystem changes.

Docker的核心概念是使创建“机器”变得容易,在这种情况下,机器可以被认为是容器。容器有助于重用性,允许您轻松地创建和删除容器。

图像描述了容器在每个时间点上的状态。所以基本的工作流程是:

创建映像 启动容器 对容器进行更改 将容器重新保存为图像

An image is like a class and container is like an object that class and so you can have an infinite number of containers behaving like the image. A class is a blueprint which isnt doing anything on its own. You have to create instances of the object un your program to do anything meaningful. And so is the case with an image and a container. You define your image and then create containers running that image. It isnt exactly similar because object is an instance of a class whereas a container is something like an empty hollow place and you use the image to build up a running host with exactly what the image says

简单地说,如果一个图像是一个类,那么容器就是一个类的实例,一个运行时对象。