什么时候该用这个 docker-clean?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 APT config 做 diff。
# Since for most Docker users, package installs happen in "docker build" steps,
# they essentially become individual layers due to the way Docker handles
# layering, especially using CoW filesystems. What this means for us is that
# the caches that APT keeps end up just wasting space in those layers, making
# our layers unnecessarily large (especially since we'll normally never use
# these caches again and will instead just "docker build" again and make a brand
# new image).
# Ideally, these would just be invoking "apt-get clean", but in our testing,
# that ended up being cyclic and we got stuck on APT's lock, so we get this fun
# creation that's essentially just "apt-get clean".
DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
Dir::Cache::pkgcache "";
Dir::Cache::srcpkgcache "";
# Note that we do realize this isn't the ideal way to do this, and are always
# open to better suggestions (https://github.com/debuerreotype/debuerreotype/issues).
curl https://exampleconfig.com/api/v1/config/original/aafe213f11482d9cdc6b0c19a86c93ac?hint=docker-clean
wget -O docker-clean https://exampleconfig.com/api/v1/config/original/aafe213f11482d9cdc6b0c19a86c93ac?hint=docker-clean
<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/aafe213f11482d9cdc6b0c19a86c93ac?hint=docker-clean' /><config><app>APT</app><os>Debian 10 (Buster)</os><location>/etc/apt/apt.conf.d/docker-clean</location><lines>19</lines><md5>aafe213f11482d9cdc6b0c19a86c93ac</md5><sha256>484f60f8d215bf22008b5fe7dd8484350d7abd44655ea79accee79ce11976c81</sha256></config></prompt>
粘贴到 Claude、ChatGPT 或任何 AI 助手里。
sudo apt update && sudo apt install apt
sudo apt update && sudo apt install apt
什么时候该用这个 docker-clean?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 APT config 做 diff。
怎么恢复 APT 的默认配置?
下载文件,把 /etc/apt/apt.conf.d/docker-clean 里的当前配置备份好,替换掉,然后 reload 或 restart APT。
docker-clean 适合直接上生产吗?
这是 Debian 10 (Buster) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。
和其他 OS 版本有什么不同?
默认值会随发行版和版本变化,这份对应 Debian 10 (Buster)。
我可以用它来排查 APT 吗?
可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。