Docker映像和容器之间有什么区别? [英] What is the difference between a Docker image and a container?

查看:94
本文介绍了Docker映像和容器之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When using Docker, we start with a base image. We boot it up, create changes and those changes are saved in layers forming another image.

因此,最终我为PostgreSQL实例创建了一个图像,为Web应用程序创建了一个图像。 ,对它们的更改会一直保留。

So eventually I have an image for my PostgreSQL instance and an image for my web application, changes to which keep on being persisted.

什么是容器?

推荐答案

图像的实例称为容器。您有一张图像,该图像是您描述的一组图层。如果启动此映像,则该映像具有正在运行的容器。您可以有许多运行中的同一图像容器。

An instance of an image is called a container. You have an image, which is a set of layers as you describe. If you start this image, you have a running container of this image. You can have many running containers of the same image.

您可以使用 docker images 查看所有图像。可以使用 docker ps 查看正在运行的容器(并且可以看到所有具有 docker ps -a 的容器)。

You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a).

因此,正在运行的图像实例是容器。

So a running instance of an image is a container.

这篇关于Docker映像和容器之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆