How To Config apt-chacher-ng


APT-Cache-ng is a Life Saver for Situation which you do not want to Give Internet to Your Ubuntu Servers for Updating Packages

apt cacher is a caching proxy for Debian based distributions that creates a local cache of Debian-based mirrors as well as other Linux distributions. This means that whenever a package is pulled from the official repositories, an APT cache server caches them such that if any other local machine would want to install the same package, it just pulls it from the local caching server. This helps eliminates the bottlenecks of slow internet connections.

Apt-Cacher NG has been designed from scratch as a replacement for apt-cacher, but with a focus on maximizing throughput with low system resource requirements. It can also be used as replacement for apt-proxy and approx with no need to modify clients’ sources.list files.

In This Article we want to implement APT-Cacher NG


1- Easily you can install APT-Cacher-ng by run Following Command :

					apt-get install  apt-cacher-ng

2- Enable APT cacher in Startup by doing :
					systemctl enable apt-cacher-ng


1- Update apt repository and install APT-Transport which allows us to add new repository easily

					sudo apt-get update
 sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \

2- Add Official Docker ‘s GPG key

					 curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

3- Add Docker Repository

					echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

4- Install Docker-Ce

					 sudo apt-get update
 sudo apt-get install docker-ce docker-ce-cli

5- Install Docker-compose for Bringing Apt-cacher-ng Container up

					 sudo chmod +x /usr/local/bin/docker-compose

6- Make a docker-compose.yml and Paste following Parameter :

version: '3'
    image: sameersbn/apt-cacher-ng
    container_name: apt-cacher-ng
    - "3142:3142"
    - apt-cacher-ng:/var/cache/apt-cacher-ng
    restart: always

7- Bring up your Docker-cmpose by doing :

					docker-compose up -d

8- You can Get access to APT   cacher by entering your http://Machine IP:3172 (

8-1  As you can see we can get access to Statistics (how much package cached) by clicking on Statistics and report and Configuration Page

We have 2 option for  configuring Client To Give  Packages From  APT-Cacher-NG

1- Send All APT Repository Requests to the Proxy Section By Creating  /etc/apt/apt.conf.d/02proxy File  and Put Following Section To IT :

					Acquire::http { Proxy ""; };
# is our apt-cacher-ng ip


2- Appending your APT Cacher URL:PORT to Your APT Repository Like:

					deb stable main contrib non-free
deb-src stable main contrib non-free
deb http://192.168.110..200:3142/HTTPS/// docker main


You Can Cache Packages , Speed UP Downloading Packages and Also Not Accessing Your Servers To the Internet By Simply Using APT Cacher-NG

Leave a Comment