I have set up apt-cacher-ng on my laptop

cat /etc/apt/apt.conf.d/02proxy 
Acquire::http { Proxy "http://localhost:3142"; };

I can install a package, turn off the internet, remove the package and install it again.

find /var/cache/apt-cacher-ng -name "*komp*"

However, in a chroot I can't install the same package when the internet is off.

I create the chroot like this:

mkdir work
cd work

#This is a backup of a previous bootstrapped using --foreign
cp ../deboot.tgz .
sudo tar -xf deboot.tgz
sudo DEBOOTSTRAP_DIR=deboot/debootstrap/ debootstrap --second-stage --second-stage-target $(readlink -f deboot)

#Set locale settings  in chroot
sudo chroot deboot locale-gen "en_US.UTF-8"
sudo chroot deboot  dpkg-reconfigure --frontend=noninteractive locales

#Set apt cache proxy in chroot
echo 'Acquire::http { Proxy ""; };' | sudo tee deboot/etc/apt/apt.conf.d/00aptproxy

# mount the /proc filesystem in the chroot (required for managing processes)
sudo mount -o bind /proc deboot/proc

sudo chroot deboot

Now in the chroot I do:

cat etc/apt/apt.conf.d/00aptproxy
Acquire::http { Proxy ""; };

root@myhostname:/# apt-get install komparator
Reading package lists... Done
Building dependency tree... Done
E: Unable to locate package komparator

If I do apt-get update in the chroot I get the following:

root@myhostname:/# apt-get update
Ign:1 http://archive.ubuntu.com/ubuntu zesty InRelease
Err:2 http://archive.ubuntu.com/ubuntu zesty Release
500  Connection failure: Network is unreachable
Reading package lists... Done
E: The repository 'http://archive.ubuntu.com/ubuntu zesty Release' does no longer have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

How do I make the chroot install packages using apt-cacher-ng on the host?

  • apt update was missing. – Ipor Sircer Oct 29 '17 at 22:32
  • Updated question with error from apt update – opticyclic Oct 30 '17 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.