首页 > 热点
云计算核心技术Docker教程:清理未使用的Docker网络
发布日期:2026-11-14
浏览次数:{固定数字3}

Docker采取了一种保守的方法来清理未使用的对象(通常称为“垃圾收集”),例如图像,容器,卷和网络:除非您明确要求Docker这样做,否则通常不会删除这云计些对象。这可能会导致Docker使用额外的磁盘空间。对于每种类型的对象,Docker提供一个prune命令。此外,您可以docker system prune用来一次清算核除多种类型的对象。

清理网络

Docker网络不会占用太多磁盘空间,但它们确实会创建iptables 规则,桥接网络设备和路由表条目。要清理这些东西,您可以docke心技r network prune用来清理任何容器都没有使用的网络。

$ docker network prune

WARNING! This will remove all netw术Dorks not used by at least one container.

Are you sure you want to continue? [y/N] y

默认情况下,系统会提示oc您继续。要绕过提示,请使用-f或 --force标志。

默认情况下,将删除所有未使用的网络。您可以使用该--filter标志限制范围。例如,以下命令仅删除24小ke时之前的网络:

$ docker network prune --filter "until=24h"

全部清理

该docker system prune命令是修剪图像,容器和r教网络的快捷方式。默认情况下,不修剪卷,并且必须指定--volumes用于docker system prune修剪卷的 标志。

$ docker system prune

W程:ARNING! This will remove:

- all stopped containers

- all networks not used by at least one contai清理ner

- all dangling images

- all build cache

Are you sure you want to continue? [y/N] y

要同时修剪卷,请添加--未使volumes标志:

$ docker system prune --volumes

WARNING! This will remove:

- all stopped contain用的ers

- all networks not used by at least one container

- all volumes not used by at least one contDoainer

- all dangling images

- all build cache

Are you sure you want to continue? [y/N] y

默认情况下,系统会提示ck您继续。要绕过提示,请使用-f或 --force标志。

上一篇:标签: 豆包 联想 智界RX 余承东
下一篇:多云管理:技术、人员、流程面临的挑战
相关文章