I’m playing with Docker
and I’m constantly tuning my
to install the needed packages.
This continuous refinement forces the build process to download the same deb packages every time and it becomes an actual waste of time and bandwidth.
apt-cacher-ng is a service which can be run on a Debian or Ubuntu host and will serve as a local cache for deb packages from Debian or Ubuntu repositories.
That’s what I need because I’m on an Ubuntu machine emulating a Debian container.
The setup is really easy:
# aptitude install apt-cacher-ng
After the installation I changed the bind address of the service to keep it local (I don’t need LAN exposure), I added my local proxy to reach the internet and I disabled
ReuseConnections (see Problems):
root@yoda:/etc/apt-cacher-ng# diff acng.conf acng.conf.old
< BindAddress: localhost 172.17.42.1
< proxy: http://127.0.0.1:5865
< ReuseConnections: 0
On the client side it’s necessary to force apt requests to use the proxy.
Dockerfile I added
RUN echo 'Acquire::http::Proxy "http://172.17.42.1:3142";' > /etc/apt/apt.conf.d/90-apt-cacher.conf
which creates the configuration file read by
aptitude when downloading packages.
apt-cacher-ng server seems buggy at least when used in conjunction with a regular proxy. Sometimes I get errors like these on the client side
Err http://http.debian.net/debian/ wheezy/main netbase all 5.0
500 Invalid header
one possible solution is to perform a
# apt-get update
on the host machine (it seems to help). Another useful setting is
as explained before.