運行環(huán)境
OS:Win10 1909(內(nèi)部版本18363.481)
WSL:1
Linux Distribution:Ubuntu 20.04
docker:20.10.6
錯誤信息
查看本地docker鏡像時提示:
root@localhost:~# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
解決辦法
- 首先確認(rèn)是否啟動了docker
root@localhost:~# ps -ef | grep docker
root 39 10 0 14:17 pts/0 00:00:00 grep --color=auto docker
如上圖所示,就是docker沒有啟動灾锯,使用如下命令啟動docker后:
root@localhost:~# service docker start
* Starting Docker: docker [OK]
重新檢查docker進(jìn)程是否存在:
root@localhost:~# ps -ef | grep docker
root 90 9 0 14:21 ? 00:00:00 /usr/bin/dockerd -p /var/run/docker.pid
root 105 90 0 14:21 ? 00:00:00 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
root 247 10 0 14:22 pts/0 00:00:00 grep --color=auto docker
如上信息表示docker已成功啟動屎勘。
- 如果docker未能啟動成功,查看docker啟動日志
/var/log/docker.log
(Ubuntu)击孩,如果日志末尾是如下錯誤信息:
time="2021-05-31T20:44:03.396093900+08:00" level=warning msg="Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.4 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)\nPerhaps iptables or your kernel needs to be upgraded.`, error: exit status 3"
time="2021-05-31T20:44:03.632996500+08:00" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
time="2021-05-31T20:44:03.633028700+08:00" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby
time="2021-05-31T20:44:03.633035700+08:00" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd
time="2021-05-31T20:44:04.633797400+08:00" level=warning msg="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
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.8.4 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
(exit status 3)
則需要將WSL1升級為WSL2焙压,升級更新操作可以參考在Win10中安裝Ubuntu中的“更新到WSL 2”章節(jié)忆家。