0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

新規インストールしたDebian 12にDockerを入れる時に泥沼に嵌った話

0
Last updated at Posted at 2026-09-02

経緯

Debian 8で動いているレガシーなシステムをDebian 12へ移行する時に発生した珍現象の話。
Debian 12を新規インストールした仮想マシンを用意してDockerを放り込めば終わりだと思っていた午前1時。

インストール用のコマンドを流し込んでしばらくしてからの話。

# パッケージの更新と必要ツールの導入
sudo apt update
sudo apt install -y ca-certificates curl gnupg

# Docker公式GPG鍵用のディレクトリ作成と鍵の取得
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER

あとは hello-worldが終われば環境構築終わりだと思っていました。

sudo docker run hello-world
docker: Error response from daemon: failed to resolve reference "docker.io/library/hello-world:latest"
: failed to do request: Head "https://registry-1.docker.io/v2/library/hello-world/manifests/latest"
: dial tcp: lookup registry-1.docker.io on [********]:53: server misbehaving

なんで?

原因はわかれば単純なことだったので先に結論を。

結論

原因

以下の問題によりDNS名前解決が出来なかった。

1.Debian新規インストール時の /etc/resolv.conf 生成漏れ
2.ローカルDNSによる大容量UDPレスポンス(EDNS0)の疎通拒否
3.スプリットDNS構成

解決法

dnsmasqをインストールして問い合わせ先を振り分けるようにした。

/etc/dnsmasq.conf
server=8.8.8.8
server=1.1.1.1
server=/example.internal/192.168.254.254
server=/example.com/192.168.254.254
edns-packet-max=1232
/etc/docker/daemon.json
{
  "dns": ["192.168.254.200"]
}
/etc/resolv.conf
nameserver 192.168.254.200

127.0.0.1と書くとDockerコンテナ内部からlocalhostを参照してエラーになるので、
ホストの外側アドレスを記述するのがポイント。

/etc/network/interfaces .
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens18
iface ens18 inet static
 address 192.168.254.200/24
 gateway 192.168.254.254
 
# This is an autoconfigured IPv6 interface
iface ens18 inet6 auto

解決までの道のり

/etc/resolv.conf
nameserver 192.168.254.254

嵌った理由がnslookupだと名前解決できるのにDockerからは名前解決できなかった点。

nslookup -type=AAAA registry-1.docker.io 192.168.254.254
Server:         192.168.254.254
Address:        192.168.254.254#53

Non-authoritative answer:
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc02:636c:9500:4e52:86b6
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc01:f9af:de63:12da:598d
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc02:c55c:72b:e74c:428c
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc00:2672:ecc7:69d9:6b47
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc00:6f54:ff30:eec:3810
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc00:cbee:96fb:ce97:e5ca
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc00:fe:c865:476b:8d94
Name:   registry-1.docker.io
Address: 2600:1f18:2148:bc01:576f:6bd:6c27:4ce4 

geminiに考えられる理由を聞くと、EDNS0が通らないのでは?との回答。
コアルータがRTX1200なので、ここで原因が判明する。

また、今まで複数回Debian新規インストールをしてきたが、/etc/resolv.confの生成漏れというケースを初めて踏んだのも盲点だった点。

で、最終的に無事hello-worldできました。(この時点で午前3時)

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4f55086f7dd0: Pull complete
d5e71e642bf5: Download complete
Digest: sha256:5dd0d3e6e255913fc30f90b9f2b1d359cc2cbdb48090cc4b65f1676e203243cc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

総評

嵌った時は一旦寝ろ。
16時間通しで作業していて単純な原因に気づくまで時間がかかったというアホな話でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?