在window10系统应用商店里安装了ubuntu系统,想在里面搭建docker.安装完之后使用命令
sudo service docker start启动服务,显示 * Starting Docker: docker,但是使用 sudo service docker status 查看服务状态的时候却是 * Docker is not running。
使用docker version看到docker的服务端根本没有启动起来。服务端显示:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
这时候使用 命令:dockerd,这个就是查看docker daemon 运行的信息的,在上面可以看到具体的错误:
第一次查看,是因为 etc/docker/daemon.json里面出现了错误的字符串。因为注释没有去掉
root@username:/# dockerd
unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character '#' looking for beginning of object key string
二,这次修改后再次查看 出现了另外的错误信息,看最后一部分的错误提示
.........
......
WARN[2023-01-09T10:43:36.415385900+08:00] Your kernel does not support cgroup blkio throttle.read_iops_device
WARN[2023-01-09T10:43:36.415391500+08:00] Your kernel does not support cgroup blkio throttle.write_iops_device
INFO[2023-01-09T10:43:36.415605000+08:00] Loading containers: start.
INFO[2023-01-09T10:43:36.592687100+08:00] stopping event stream following graceful shutdown error="<nil>" module=libcontainerd namespace=moby
INFO[2023-01-09T10:43:36.593693700+08:00] stopping event stream following graceful shutdown error="context canceled" module=libcontainerd namespace=plugins.moby
INFO[2023-01-09T10:43:36.593792500+08: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))
最后经过搜错发现,是因为最新版的ubuntu系统使用了iptables-nft,而WSL2不支持导致的。
需要使用如下命令修改信息:
root@username:/# update-alternatives --config iptables
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/sbin/iptables-nft 20 auto mode
1 /usr/sbin/iptables-legacy 10 manual mode
2 /usr/sbin/iptables-nft 20 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode
选择编号1的。
再次启动docker,已经可以了。
root@username:/# service docker start
* Starting Docker: docker [ OK ]
root@username:/# service docker status
* Docker is running
root@username:/# docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:01:58 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 17:59:49 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.12
这时候看到使用 docker version命令,服务端也有信息了。
这里最主要的就要使用命令:dockerd来查看具体的报错信息,定位问题。
解决2参考链接:https://blog.csdn.net/0210/article/details/124349371
在Windows 10的Ubuntu子系统中安装Docker后,启动服务时遇到问题。尝试用`sudo service docker start`启动但状态显示未运行。通过`docker version`发现服务端未启动,错误提示无法连接到Docker守护进程。使用`dockerd`命令查看详细错误,发现`etc/docker/daemon.json`配置文件有误以及iptables-nft与WSL2不兼容的问题。解决方法是修改iptables配置,并通过`dockerd`命令定位和解决问题。参照链接提供的解决方案,成功启动Docker服务。

3670

被折叠的 条评论
为什么被折叠?



