This repository is associated with a blog post, for more details please head to the post from here.
Dockerfile features:
- Allows binding of apt-cacher-ng cache directory with a host directory.
- Allows SSL/TLS proxying (Keep in mind that this will not cache secured traffic because its encrypted).
- Build server image
docker build -t custom-apt-cacher-ng .
- Run a container based on the image built
docker run -d \
-p 127.0.0.1:3142:3142 \
-v /path/to/cache:/var/cache/apt-cacher-ng
--name apt-cacher-ng \
custom-apt-cacher-ng
- Check logs (
ctrl + c
to exit)
docker logs -f apt-cacher-ng
- Build server image
docker-compose build
- Run a container based on the image we just built
docker-compose up -d
- Check logs (use
ctrl + c
to exit)
docker-compose logs -f
- Create an empty proxy file
sudo nano /etc/apt/apt.conf.d/01proxy
- Paste the following line there
Acquire::http { Proxy "http://SERVER_IP:3142"; };
- Very important to execute when manipulating APT proxying
sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.bak # or delete it, preferred to make a backup
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update
Let's verify that the setup is working via a simple sudo apt-get update, then head to http://localhost:3142/acng-report.html
and we should see some content being downloaded and cached for the next requests.
We just set up the apt proxy using either Docker or Docker Compose with ease and we tested the setup using the local host.
Consider buying us a coffee ❤️