
mbentley/apt-cacher-ng基于Debian(trixie/bookworm/bullseye)的apt-cacher-ng Docker镜像,主要用途是作为APT包缓存服务器,通过缓存Debian/Ubuntu系统的软件包,减少重复下载,加速软件包安装过程,降低网络带宽消耗。
以下标签支持amd64和arm64架构,系统会根据主机架构自动拉取对应版本:
latesttrixiebookwormbullseye也可使用架构特定标签显式指定架构:
latest-amd64, trixie-amd64latest-arm64, trixie-arm64bookworm-amd64, bookworm-arm64bullseye-amd64, bullseye-arm64latest、trixie、bookworm和bullseye标签每日生成唯一清单,格式为<tag>-YYYYMMDD(如latest-20220215),可在Docker Hub查看。这些标签为时间点快照,保留6个月且不接收安全更新,建议仅需固定镜像摘要时使用,否则优先选择常规标签。
适用于需管理多个Debian/Ubuntu系统的环境:
bashdocker run -d \ --name apt-cacher-ng \ -p 3142:3142 \ -e TZ="US/Eastern" \ -e PUID=0 \ -e PGID=0 \ -v /data/apt-cacher-ng:/var/cache/apt-cacher-ng \ mbentley/apt-cacher-ng
-d:后台运行容器--name apt-cacher-ng:指定容器名称-p 3142:3142:映射容器3142端口(apt-cacher-ng默认端口)到宿主机-e TZ:设置时区(如"Asia/Shanghai")-e PUID/PGID:设置运行用户/组ID(默认0即root,可改为非root值)-v:挂载宿主机目录到容器缓存目录,实现缓存数据持久化| 环境变量 | 说明 | 默认值 |
|---|---|---|
| TZ | 容器运行时区 | 未设置 |
| PUID | 运行用户ID | 0 (root) |
| PGID | 运行用户组ID | 0 (root) |
在Debian/Ubuntu客户端创建或修改/etc/apt/apt.conf文件,添加代理配置:
Acquire::http::Proxy "http://<docker-host>:3142";
将<docker-host>替换为运行容器的宿主机IP或域名。
在客户端/etc/apt/apt.conf中为特定仓库设置直接连接:
Acquire::HTTP::Proxy::<repo-url> "DIRECT";
示例(绕过Docker和VirtualBox仓库):
Acquire::HTTP::Proxy::get.docker.com "DIRECT"; Acquire::HTTP::Proxy::download.virtualbox.org "DIRECT";
修改容器内/etc/apt-cacher-ng/acng.conf,添加PassThroughPattern规则:
PassThroughPattern: get\.docker\.com PassThroughPattern: download\.virtualbox\.org
建议:通过数据卷挂载持久化配置文件(如-v /path/to/acng.conf:/etc/apt-cacher-ng/acng.conf),避免容器重启后配置丢失。
服务启动后,访问http://<docker-host>:3142/acng-report.html可查看缓存状态报告,确认服务运行正常。



manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务