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

查看:40
本文介绍了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 查看所有容器 -一个).

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天全站免登陆