docker 删除映像_如何在Docker中删除映像和容器

docker 删除映像

Docker RMI (Docker rmi)

docker rmi removes images by their ID.

docker rmi通过其ID删除图像。

To remove the image, you first need to list all the images to get the Image IDs, Image name and other details. By running simple command docker images -a or docker images.

要删除图像,首先需要列出所有图像以获取图像ID,图像名称和其他详细信息。 通过运行简单命令docker images -adocker images

After that you make sure which image want to remove, to do that executing this simple command docker rmi <your-image-id>. Then you can confirm that image has been removed or not by list all the images and check.

之后,确定要删除的图像,然后执行此简单命令docker rmi <your-image-id> 。 然后,通过列出所有图像并检查,可以确认图像是否已删除。

删除多张图片 (Remove multiple images)

There is a way to remove more than one images at a time, when you want to remove multiple specific images. So to do that first get Image IDs simply by listing the images then execute simple followed command.

当您要删除多个特定图像时,可以使用一种方法一次删除多个图像。 为此,首先只需列出图像即可获取图像ID,然后执行简单的后续命令。

docker rmi <your-image-id> <your-image-id> ...

docker rmi <your-image-id> <your-image-id> ...

Write Images IDs in the command followed by the spaces between them.

在命令中写入图像ID,后跟空格。

一次删除所有图像 (Remove all images at once)

To remove all images there is a simple command to do that. docker rmi $(docker images -q)

要删除所有图像,有一个简单的命令可以做到。 docker rmi $(docker images -q)

Here in the above command, there are two command the first which execute in the $() is shell syntax and returns the results whatever executed in that syntax. So in this -q- is a option is used to provide to return the unique IDs,$() returns the results of image IDs and then docker rmi removes all those images.

在上面的命令中,有两个命令,第一个在$()执行的命令是shell语法,并返回以该语法执行的结果。 因此,在此-q- is a option is used to provide to return the unique IDs, $()返回图像ID的结果,然后docker rmi删除所有这些图像。

想要查询更多的信息: (For More Information:)

码头工人 (Docker rm)

docker rm removes containers by their name or ID.

docker rm通过容器的名称或ID删除容器。

When you have Docker containers running, you first need to stop them before deleting them.

当您运行Docker容器时,首先需要停止它们,然后再删除它们。

  • Stop all running containers: docker stop $(docker ps -a -q)

    停止所有正在运行的容器: docker stop $(docker ps -a -q)

  • Delete all stopped containers: docker rm $(docker ps -a -q)

    删除所有停止的容器: docker rm $(docker ps -a -q)

删除多个容器 (Remove multiple containers)

You can stop and delete multiple containers by passing the commands a list of the containers you want to remove. The shell syntax $() returns the results of whatever is executed within the brackets. So you can create your list of containers within this to be passed to the stop and rm commands.

您可以通过向命令传递要删除的容器列表来停止和删除多个容器。 shell语法$()返回括号中执行的任何结果。 因此,您可以在其中创建容器列表,以传递给stoprm命令。

这是docker ps -a -q的细目分类 (Here is a breakdown of docker ps -a -q)

  • docker ps list containers

    docker ps列表容器

  • -a the option to list all containers, even stopped ones. Without this, it defaults to only listing running containers

    -a列出所有容器,甚至停止容器的选项。 没有这个,它默认只列出正在运行的容器

  • -q the quiet option to provide only container numeric IDs, rather than a whole table of information about containers

    -q安静选项仅提供容器数字ID,而不提供有关容器的整个信息表

更多信息: (More Information:)

有关Docker中映像的更多信息: (More info about images in Docker:)

有关Docker中容器的更多信息: (More info about containers in Docker:)

有关Docker的更多信息: (More info about Docker:)

翻译自: https://www.freecodecamp.org/news/how-to-remove-images-in-docker/

docker 删除映像

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值