Windows子系统Docker服务重启

2021-03-10  本文已影响0人  明训

背景说明

在采用WSL使用子系统的过程中,发现出现如下问题

[root@ljhan2 /]# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@ljhan2 /]#

当解决如上问题后,在重启Docker服务的时候出现如下报错

[root@ljhan2 bin]# service docker restart
Redirecting to /bin/systemctl restart docker.service
Failed to get D-Bus connection: Operation not permitted
[root@ljhan2 bin]#

解决方案

服务使用

Windows系统使用Windows+r命令打开命令行

C:\Users\Administrator>wsl -l -v
  NAME                   STATE           VERSION
* Centos-7.3             Running         2
  docker-desktop-data    Stopped         2
  docker-desktop         Stopped         2

C:\Users\Administrator>

开启软件Docker Desktop软件,开启docker服务后,再次查看子系统

C:\Users\Administrator>wsl -l -v
  NAME                   STATE           VERSION
* Centos-7.3             Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2

C:\Users\Administrator>

必须要保证docker-desktop-datadocker-desktop处于Running状态

再次执行命令查看

[root@ljhan2 bin]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS
                              NAMES
[root@ljhan2 bin]#

服务重启

替换systemctl文件

[root@ljhan2 bin]# mv /usr/bin/systemctl /usr/bin/systemctl.old
[root@ljhan2 bin]# curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > /usr/bin/systemctl
[root@ljhan2 bin]# chmod +x /usr/bin/systemctl

尝试重启

[root@ljhan2 bin]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@ljhan2 bin]#
上一篇下一篇

猜你喜欢

热点阅读