apt/apt-get commands may use SRV record to find nearby APT service. 1
However, offical Debian/Ubuntu images cannot utilize such functonality unless /etc/services file is present.
This means APT will download packages from deb.debian.org / archive.ubuntu.com as usual. 🤣
This also means local APT (cache/proxy) servers is bypassed and the build process may be slowed down if the bandwidth is limited.
Workaround
apt-get install -y netbasein the very beginning but this still down the package from remote.RUN apt-get update && apt-get install -y netbaseand let docker cache this RUN command.
Great when often rebuilt. 🛠️Acquire::http::Proxybut only useful in private use (proxy server usually behind firewall?) .- Modify
/etc/apt/sources.listor/etc/hosts, but cons as above. - Modify A/CNAME record in local DNS service and point to local APT service. This is another reliability/maintenance story.
Details
When APT query SRV, it asks the service name of port 80 with getservbyport_r(), which use /etc/services, which shipped in netbase.
http is not an easy answer there. Therefore, everything works as usual. 🤣
keywords for search engines
apt, apt-get, apt cache, apt proxy, srv records, dns, apt-cacher-ng, netbase, /etc/services
Only one entry of
/etc/servicesis needed to use apt with SRV in Debian.echo "http 80/tcp" > /etc/serviceswill do the trick instead of install netbase.