Apt-Cacher-NG LXC #2332
Replies: 14 comments 17 replies
-
Apt-Cacher-NG is incredibly helpful for me. For instance, if John Doe1 reports an issue with the Debian 12 LXC, the first step is to create a Debian 12 LXC. During this process, I cache standard dependencies like curl, sudo, and midnight commander that are used by every script. After that, It updates the Debian 12 OS packages, which are now cached. Now, if John Doe2 reports an issue with the Docker LXC, which utilizes Debian 12, I create a new Docker LXC. However, this time, I locally serve the cached packages that were cached during the creation of the Debian 12 LXC, saving bandwidth and a faster package installation. Another example is, let's say we have 15 LXCs created, and we need to update the OS. If we use the Proxmox VE LXC Updater, it updates the first LXC while caching the packages. Subsequently, the other 14 LXCs can locally utilize those cached packages. |
Beta Was this translation helpful? Give feedback.
-
A slightly easier way to configure Debian or Ubuntu to use a package cache
is to install the auto-apt-cache package (
https://salsa.debian.org/debian/auto-apt-proxy).
It requires an additional DNS record for your local network, but you only
need to do that once.
…On Sat, 13 Jan 2024 at 06:29, tteckster ***@***.***> wrote:
To enable Apt-Cacher-NG for your existing containers, execute (*after
configuring the IP*) the following command in the console of each LXC
that you wish to use with the proxy.
echo "Acquire::http { Proxy \"http://<apt-cacher-ng IP>:3142\"; };" >/etc/apt/apt.conf.d/00aptproxy
—
Reply to this email directly, view it on GitHub
<#2332>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAWPZJYXMDFGKUGWURHKATYOGMKHAVCNFSM6AAAAABBYVMOUGVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWGA3DONRSG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I find adding the package (with apt install auto-apt-proxy) easier to
remember and type, I can do it the same way in docker images, lxc, vms
or bare metal hosts.
Bonuses are:
- if I change my package cache host/port/etc, I can just change the DNS
record and everything picks it up
- the script that does the auto discovery tests that the cache is up before
returning the proxy details, so if it’s not, there is a slight delay and
apt continues connecting to the repositories.
…On Sat, 13 Jan 2024 at 23:13, tteckster ***@***.***> wrote:
Why is that considered easier?
—
Reply to this email directly, view it on GitHub
<#2332 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAWPZJ43G577YIEROYGOG3YOKB55AVCNFSM6AAAAABBYVMOUGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCMJXHEZDM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I found out that I cover 99% of the traffic with the standard apt repos, so for example if I configure manually another repo on one LXC/VM it does not make sense to cache it. Therefore I have this line in my post-deployment script which does the job for me: |
Beta Was this translation helpful? Give feedback.
-
Nice! It was easy to add! I just had an issue with https repos, specifically the postgres ones. I adjusted the The official script here adds a comment after, but somehow it's interfering. Removing the comment makes the postgres https repos that I added to a db lxc I have functional again. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to have a sort of env_var on the host that can be used by any script automatically? |
Beta Was this translation helpful? Give feedback.
-
This may not be the place for it, but I have an issue with this when trying to use this lxc on other debian containers. If the container is ubuntu it works fine:
However on debian containers I get:
|
Beta Was this translation helpful? Give feedback.
-
For anyone wanting to switch to the new method introduced here ffd2fc3, change
It will overwrite your previous |
Beta Was this translation helpful? Give feedback.
-
is there a way to delete the proxy again? |
Beta Was this translation helpful? Give feedback.
-
I think there is an even easier way to detect/add the proxy to your LXC, using avahi. Simply install the First, setup the AptCacherNG server (Ubuntu 22.04), with Then on any Debian/Ubuntu LXC that you want to use the cache server, run |
Beta Was this translation helpful? Give feedback.
-
Now it matches the system domain configured in OPNSense and I also had Unbound configured to register DHCP leases so any new services that spin up and use DHCP get registered in Unbound as To create the SRV record, since I'm using OPNSense I installed the routerperformance OPNSense repo and installed Unbound Custom Options (os-unboundcustom-maxit) plugin and added this under Services > Unbound DNS > Custom Options
Restarted Unbound DNS service and tested that the SRV record is resolved with
Connect to the shell of any Proxmox container created using the helper scripts and install
Now running
|
Beta Was this translation helpful? Give feedback.
-
Hi! I think it would be helpful to have the setup and removal of the apt-catcher in the website itself! I wasn’t sure how to use it or enable it until I took a look at this :). In any case, thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Hey! Another question. I've executed this command on all my LXCs.
I've already had some updates on the LXCs, so I wanted to either see some logs or cached files or something to know about the apt-cacher-ng. Checking their help page and looking at |
Beta Was this translation helpful? Give feedback.
-
So maybe it is helpful, but please decide on your own. I run also squid-deb-proxy and apt-cacher-ng, since years and configure that for every of my setups (debian systems), via a custom deb package. I had also struggles with some topics you discuss here, like easy config and that sometimes the acl of the proxy does not allow some sources and i need a direct declaration for that. For solving all that i did: https://github.com/hastmu/apt-proxy-detect What do you get?
Installation goes currently via: |
Beta Was this translation helpful? Give feedback.
-
To enable Apt-Cacher-NG for your existing containers, execute (after configuring the
<apt-cacher-ng-IP>
) the following command in the console of each LXC that you wish to use with the proxy. Update #2332 (comment)The scripts now have the option to utilize Apt-Cacher-NG (Advanced settings) when creating LXCs. The added functionality is expected to decrease bandwidth usage and expedite package installation and updates.
Beta Was this translation helpful? Give feedback.
All reactions