首页 > 编程知识 正文

dockerfile 删除镜像里面文件,docker删除所有容器镜像的命令

时间:2023-05-03 17:28:41 阅读:197100 作者:4119

docker删除映像

You can list all the images you have downloaded or installed using the

您可以使用列出所有已下载或安装的映像

docker images -a

command:

命令:

You can remove an image with docker rmi command, passing the name of the image you want to remove. This will remove the image.

您可以使用docker rmi命令删除图像,并传递要删除的图像的名称。 这将删除图像。

Sometimes when testing and developing, some images become dangling, which means untagged images. They can always be safely removed to free disk space.

有时在测试和开发时,有些图像会悬空,这意味着未标记的图像。 始终可以安全地删除它们以释放磁盘空间。

Running docker images -f dangling=true will list them:

运行docker images -f dangling=true将列出它们:

And you can clear them with docker rmi $(docker images -f dangling=true -q). This command will only eliminate dangling images used in containers, even if not currently running.

您可以使用docker rmi $(docker images -f dangling=true -q)清除它们。 即使当前未运行,此命令也将仅消除容器中使用的悬挂图像。

docker system prune -a, which is also a commonly used way to remove images, will also remove images not referenced by any container, which might remove images you might want to keep, even just to rollback to previous versions of an image.

docker system prune -a也是一种删除映像的常用方法,它还会删除任何容器未引用的映像,这可能会删除您可能想要保留的映像,甚至只是回滚到映像的先前版本。

You can also remove all images using docker rmi $(docker images -a -q) if you want to clean everything, which might be nice during your first tests and experiments with Docker.

如果您想清理所有内容,也可以使用docker rmi $(docker images -a -q)删除所有图像,这在您进行Docker的第一次测试和实验时可能会很好。

翻译自: https://flaviocopes.com/docker-images-command-line/

docker删除映像

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。