apt-cacher-ng を回避して Docker をインストールする

要約

apt-cacher-ng 環境下では download.docker.com へ接続できず Docker をインストールできないので

echo 'Acquire::HTTP::Proxy::download.docker.com "DIRECT";' > /etc/apt/apt.conf.d/70docker

して直接ダウンロードするようにしましょう。

なぜ書くか

毎回毎回忘れていて Twitter で 「docker from:nogiro_iota」を検索して↓を探すハメになるので自分用メモとして書いています。


本題

パッケージマネージャー apt には、パッケージのダウンロードをプロキシしてキャッシュしてくれる仕組みの apt-cacher-ng があります。
apt-cacher-ng 環境下で Docker をインストールすると download.docker.com へ接続できずに失敗します。

以下の公式のインストール手順にしたがって進めていると
docs.docker.com
INSTALL DOCKER ENGINE - COMMUNITY セクションの apt update が失敗します。(add-apt-repository の次)

$ sudo apt update
Err:1 https://download.docker.com/linux/debian buster InRelease
  Reading from proxy failed - read (115: Operation now in progress) [IP: 192.0.2.0 3142]
Hit:2 http://deb.debian.org/debian buster InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Hit:4 http://security.debian.org/debian-security buster/updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch https://download.docker.com/linux/debian/dists/buster/InRelease  Reading from proxy failed - read (115: Operation now in progress) [IP: 192.0.2.0 3142]
W: Some index files failed to download. They have been ignored, or old ones used instead.

当時調べたところ、apt の設定で apt-cacher-ng を回避する方法が出てきました。
github.com

ので設定します。(Twitter からコピーすると http:// がついてめんどかったのですよね。)

$ echo 'Acquire::HTTP::Proxy::download.docker.com "DIRECT";' > /etc/apt/apt.conf.d/70docker

apt update が成功します。

$ sudo apt update
Hit:1 http://deb.debian.org/debian buster InRelease
Get:2 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:3 https://download.docker.com/linux/debian buster InRelease [44.4 kB]
Get:4 https://download.docker.com/linux/debian buster/stable amd64 Packages [10.3 kB]
Hit:5 http://security.debian.org/debian-security buster/updates InRelease
Fetched 104 kB in 1s (79.5 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date

後書き

この記事を書いているときに調べたところ、HTTPS だと失敗するようです。
wiki.debian.org

apt-cacher-ng 側の設定で回避できそうなのでストレスフリーになりそうです。