【发布时间】:2020-04-04 16:09:42
【问题描述】:
我在 docker (Docker version 18.09.7, build 2d0083d) 上运行 ubuntu:16.04:
docker run -it ubuntu:16.04
我在里面运行apt -o APT::Keep-Downloaded-Packages=true install curl
应该安装 curl,而不是从 /var/cache/apt/archives 中删除 deb,但这不会发生。软件包已安装,但 deb 未保存在缓存中(或者更确切地说,已保存然后删除)。
我在主机上试过了:
lsb_release -a
LSB Version: core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:printing-9.20160110ubuntu0.2-amd64:printing-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
它按预期工作(即包已保存)。
检查了容器和主机中的 apt 版本。两者都运行相同的 apt - apt 1.2.32 (amd64)
主机和容器之间有什么不同会导致忽略APT option?
【问题讨论】:
-
在股票
ubuntu图像中查看/etc/apt/apt.conf/docker-clean。在典型的面向 Docker 的使用中,在 Dockerfile 中只会调用一次或两次对apt-get install的调用,之后将永远不会调用它,因此保留.deb文件是没有用的,它们会自动清理。 -
酷!我检查了我的
/etc/apt/apt.conf.d/docker-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"; };。我想删除这两行可以解决我的问题,即使不调用 APT 选项