🎃

Troubleshoot: WSL2でDockerが起動しない

2022/08/07に公開約1,700字

事象

WSL2でDockerが起動しない。

$ sudo service docker start
 * Starting Docker: docker                                    [ OK ]
$ sudo service docker status
 * Docker is not running

Dockerのログを確認すると下記の通り。

INFO[2022-05-01T15:20:54.353308700+09:00] Loading containers: start.
INFO[2022-05-01T15:20:54.390815400+09:00] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
INFO[2022-05-01T15:20:54.391117000+09:00] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
INFO[2022-05-01T15:20:54.391126400+09:00] stopping healthcheck following graceful shutdown  module=libcontainerd
failed to start daemon: Error initializing network controller: error obtaining controller instance: unable to add return rule in DOCKER-ISOLATION-STAGE-1 chain:  (iptables failed: iptables --wait -A DOCKER-ISOLATION-STAGE-1 -j RETURN: iptables v1.8.7 (nf_tables):  RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1
 (exit status 4))
WARN[2022-05-01T15:20:55.391786300+09:00] grpc: addrConn.createTransport failed to connect to {unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}. Err :connection error: desc = "transport: Error while dialing dial unix:///var/run/docker/containerd/containerd.sock: timeout". Reconnecting...  module=grpc

原因

Dockerが新しいiptablesに対応できないため。

対策

Legacy版のiptablesを使うようにする。

$ sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
$ sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

参考

Discussion

ログインするとコメントできます