Docker删除不使用的对象

登录到Docker主机并打开命令提示符。
然后执行以下命令删除已停止的容器、悬空镜像(Dangling images)和所有未使用的网络。

docker system prune

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache
Are you sure you want to continue? [y/N]

默认命令将提示进行确认。
按' y '继续。
要忽略确认提示,使用' -f '或' -force '标志,如下所示

docker system prune --force

要删除所有未使用的镜像,请使用“-all”或“-a”标志的prune命令。

docker镜像由多层组成。
悬空镜像(Dangling images)是与任何标记镜像没有关系的层。

docker system prune --all

默认情况下,docker system prune命令不会删除未使用的卷,以防止意外的数据丢失。
但是你也可以使用“--volumes”标志来prune卷:

docker system prune --volumes

如何删除Docker中所有未使用的对象

docker system prune命令用于删除docker上所有未使用的对象。
此命令将删除任何已停止的容器、未使用的镜像和所有未使用的网络。

日期:2019-04-29 03:17:12 来源:oir作者:oir