A lightweight APT / APK / YUM Cache Proxy - just over 2MB in size!
810
A lightweight (< 10MB), high-performance caching proxy for Linux package managers (APT, YUM/DNF, APK). It accelerates package installation by caching packages locally, drastically reducing build times and bandwidth consumption across server fleets and container build pipelines.
apt), CentOS (yum/dnf), and Alpine (apk)./healthz, /livez, /readyz, and Prometheus /metrics endpoints./api/cache/stats, /api/cache/purge, /api/cache/cleanup, /api/mirrors/refresh).Multi-arch Docker images are pushed to Docker Hub (lj020326/apt-proxy) and GitHub Container Registry (ghcr.io/lj020326/apt-proxy):
linux/amd64linux/arm64linux/arm/v7Run APT Proxy using a persistent volume for the local cache directory:
docker run -d \
--name apt-proxy \
-p 3142:3142 \
-v apt-proxy-cache:/var/cache/apt-proxy \
lj020326/apt-proxy:latest
Pass the proxy via environment variable during package operations:
export http_proxy=http://<HOST_IP>:3142
apt-get update && apt-get install -y vim
Speed up package installs inside your image builds:
FROM ubuntu:24.04
ARG APT_PROXY
ENV http_proxy=${APT_PROXY}
RUN apt-get update && apt-get install -y \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
Build passing your proxy container's address:
docker build --build-arg APT_PROXY=[http://172.17.0.1:3142](http://172.17.0.1:3142) -t my-app .
Configuration can be passed via CLI arguments, environment variables, or a mounted YAML configuration file (/etc/apt-proxy/apt-proxy.yaml).
| Variable | Default | Description |
|---|---|---|
APT_PROXY_HOST | 0.0.0.0 | Network interface to bind |
APT_PROXY_PORT | 3142 | Server listening port |
APT_PROXY_MODE | all | Distribution mode (all, ubuntu, debian, centos, alpine) |
APT_PROXY_CACHEDIR | /var/cache/apt-proxy | Local cache directory |
APT_PROXY_CACHE_MAX_SIZE | 10 | Max cache size in GB (0 disables LRU eviction) |
APT_PROXY_CACHE_TTL | 168 | Cache TTL in hours (0 disables TTL eviction) |
APT_PROXY_API_KEY | None | API key for protected endpoints (enables API auth) |
APT_PROXY_STORAGE_BACKEND | disk | Storage backend (disk or s3) |
To share cache across container replicas or outlive ephemeral nodes, point storage to an S3-compatible backend:
docker run -d \
--name apt-proxy \
-p 3142:3142 \
-e APT_PROXY_STORAGE_BACKEND=s3 \
-e APT_PROXY_S3_ENDPOINT=minio.example.com:9000 \
-e APT_PROXY_S3_BUCKET=apt-cache \
-e APT_PROXY_S3_ACCESS_KEY=your-access-key \
-e APT_PROXY_S3_SECRET_KEY=your-secret-key \
-e APT_PROXY_S3_USE_PATH_STYLE=true \
lj020326/apt-proxy:latest
version: '3.8'
services:
apt-proxy:
image: lj020326/apt-proxy:latest
container_name: apt-proxy
restart: unless-stopped
ports:
- "3142:3142"
environment:
- TZ=UTC
- APT_PROXY_CACHE_MAX_SIZE=20
- APT_PROXY_CACHE_TTL=168
volumes:
- apt-proxy-cache:/var/cache/apt-proxy
- /etc/localtime:/etc/localtime:ro
volumes:
apt-proxy-cache:
Content type
Image
Digest
sha256:2baf2fdb0…
Size
10.3 MB
Last updated
1 day ago
docker pull lj020326/apt-proxy