在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。
因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。
什么是容器?
在使用Docker时,我们从一个基本映像开始。我们启动它,创建更改,这些更改被保存在图层中形成另一个图像。
因此,最终我为我的PostgreSQL实例和我的web应用程序提供了一个图像,对这些图像的更改将持续保存。
什么是容器?
当前回答
虽然将容器看作一个运行的映像是最简单的,但这并不十分准确。
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 images看到你所有的图像,而你可以用docker ps看到你正在运行的容器(你可以用docker ps -a看到所有的容器)。
因此,映像的运行实例就是一个容器。
虽然将容器看作一个运行的映像是最简单的,但这并不十分准确。
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容器正在运行一个映像的实例。你可以将图像与程序关联起来,将容器与进程关联起来:)
Image相当于OOP中的类定义,层是该类的不同方法和属性。
容器是图像的实际实例化,就像对象是实例化或类的实例一样。