# 清理旧的容器镜像

**URL:** <https://meta.discourse.org/t/cleaning-up-old-container-images/147367>\
**Category:** Self-hosting\
**Created:** [2020年四月9日 00:42 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367 "2020-04-09T00:42:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)\
**Post date:** [2020年四月9日 00:42 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/1 "2020-04-09T00:42:02Z")

</div>

> [@Falco](#):
>
> 为什么会有让东西变快的秘密命令？

哈哈，好吧，不是为了让它“变快”，但确实有一个命令是用来清理空间的！😉 我说的当然是：

`./launcher cleanup`

这个命令会在磁盘空间不足时清除旧的镜像。这是我个人不得不运行过多次的事情，而且除非你知道去哪里找，否则它并不显而易见，此外，多年来在 Meta 上，这个问题至少已经出现过“数十次”之多。

我之所以提这个，是因为我实在不明白为什么“清理”不能自动进行，比如每月一次和/或每次重建时自动执行 😃 我不明白为什么默认情况下要一直保留所有旧的容器。

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2020年四月9日 01:06 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/2 "2020-04-09T01:06:11Z")

</div>

> [@bts](#):
>
> 除非你知道去哪里找，否则它存在这一点并不明显

如今，当你的磁盘可用空间少于 5GB 时，我们会交互式地运行此命令。

---

<div class="post-metadata">

**Author:** ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)\
**Post date:** [2020年四月9日 01:19 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/3 "2020-04-09T01:19:46Z")

</div>

啊，明白了，是的，这样确实更难被忽略！不过感觉它还是应该作为一个后台任务来运行，这样就不需要任何人手动执行了。（除非我漏掉了什么，或者有时确实有理由保留那些旧的未使用的容器）

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年四月9日 02:10 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/4 "2020-04-09T02:10:30Z")

</div>

> [@bts](#):
>
> 除非我漏掉了什么，否则有时确实有理由保留旧的未使用的容器

你无法猜测为什么有人可能想保留旧的容器。我有一些十年前淘汰的电脑留下的整个硬盘。我不希望别人擅自决定删除它们。😉

---

<div class="post-metadata">

**Author:** ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)\
**Post date:** [2020年四月9日 02:25 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/5 "2020-04-09T02:25:37Z")

</div>

哈哈，你说得对。我这么问只是因为我真的不知道那些理由会是什么：思考：：倒脸：

当然，我理解为了实际数据保留目的而保留备份。但旧的容器是不同的吧？我不是 Docker 专家，这大概是个不太恰当的比喻，但对我来说，这感觉就像我在使用 macOS Catalina，却保留了 Mojave、High Sierra、Sierra、El Capitan、Yosemite 等旧版本的副本。

我并不是怀疑你所说的保留容器有……理由！只是在我多年使用 Discourse 的过程中从未遇到过这些情况，所以猜测像我这样使用默认安装的 99% 的用户可能永远都不需要它们。如果有一个选项可以_始终_自动清理旧的容器，我一定会使用它！

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月9日 02:38 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/6 "2020-04-09T02:38:32Z")

</div>

> [@bts](#):
>
> 我使用的是 macOS Catalina，但保留了 Mojave、High Sierra、Sierra、El Capitan、Yosemite 等系统的副本。

我的意思是，插件在重大更新期间经常会失效，尤其是第三方插件。这与 macOS 重大版本更新导致某些应用无法运行的情况类似。

---

<div class="post-metadata">

**Author:** ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)\
**Post date:** [2020年四月9日 02:59 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/7 "2020-04-09T02:59:18Z")

</div>

啊，所以你的意思是保留旧容器有用，以防出现问题时需要回滚？在这种情况下，是只需要保留上一个容器，还是偶尔也需要很久以前的容器？

我知道 macOS 的类比并不完美，但我的观点是，我绝不会回退到非常旧的操作系统，即使某些遗留应用只能在最新版本上运行。如果有人能给我一个具体的例子，比如“看，这里确实有个情况，我不得不使用两年前那个旧的 Discourse 容器”，那我就闭嘴了 🙂 说实话，这其实是我很久以来一直好奇的问题。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年四月9日 08:17 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/8 "2020-04-09T08:17:48Z")

</div>

我的类比并不完美。但有些人可能拥有未使用的 Docker 镜像和容器，他们不希望删除这些资源，因为他们只是偶尔运行它们，而不想在下一次需要时重新构建。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2024年五月4日 21:44 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/9 "2024-05-04T21:44:03Z")

</div>



---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2024年五月4日 22:30 UTC](https://meta.discourse.org/t/cleaning-up-old-container-images/147367/10 "2024-05-04T22:30:17Z")

</div>


