ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

WSL2(Ubuntu22.04)環境でDockerのコマンドを実行すると「ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?」というエラーが出ました。

サービス起動します。

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

サービスを起動できないのでログを見ます。

$ sudo tail -f /var/log/docker.log
...
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))

このエラーが出た場合、以下コマンドを実行し、再度サービス起動します。

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

参考サイト

WSL2 Kernel do not support `nftables` and causing docker failed to start up in Ubuntu 20.10+ · Issue #6655 · microsoft/WSL
Environment Windows build number: 21327 Your Distribution version: Ubuntu Hirsute Hippo (development branch) Whether the...

コメント

株式会社CONFRAGE ITソリューション事業部をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む

タイトルとURLをコピーしました