Public | Automated Build

Last pushed: 8 months ago
Short Description
Caching for apt-get - useful if you tend to rebuild your Dockerfiles often
Full Description

Docker uwegerdes/apt-cacher-ng

A docker for caching apt repositories. The files should be saved on your host system so this docker image / container can be rebuilt without loosing the cached data.


Create the cache directory and start the apt-cacher-ng container:

$ sudo mkdir -p /srv/docker/apt-cacher-ng
$ sudo chmod a+w /srv/docker/apt-cacher-ng
$ docker build -t uwegerdes/apt-cacher-ng --build-arg TZ="Europe/Berlin" .
$ docker run -d \
    --restart=always \
    --name apt-cacher-ng \
    --hostname apt-cacher-ng \
    -p 3142:3142 \
    -v /srv/docker/apt-cacher-ng:/var/cache/apt-cacher-ng \

Configuration and information about the cache is available with your browser, open http://localhost:3142/acng-report.html or the ip:port of the computer running apt-cacher-ng.

You should open port 3142 in your firewall to allow access from the docker-engine (on another network in your PC!), in my case it's ufw:

$ sudo ufw allow to any port 3142


Add the following lines to your Dockerfile (see uwegerdes/baseimage):

RUN if [ -n "${APT_PROXY}" ]; then \
        echo "Acquire::http { Proxy \"${APT_PROXY}\"; };" >> /etc/apt/apt.conf.d/01proxy; \
        echo "Acquire::https { Proxy \"https://\"; };" >> /etc/apt/apt.conf.d/01proxy; \

To have a cache for building virtual machines please use those commands (with your local ip) in the VM:

echo "Acquire::http { Proxy \"\"; };" >> /etc/apt/apt.conf.d/01proxy
echo "Acquire::https { Proxy \"https://\"; };" >> /etc/apt/apt.conf.d/01proxy
Docker Pull Command
Source Repository