WSL2 尝试卸载dockers,发现一直报错,原因docker 这个服务已经停了,而无法卸载,尴尬
Removing docker-ce (5:20.10.7~3-0~debian-buster) ...
invoke-rc.d: could not determine current runlevel
[....] Stopping Docker: dockerstart-stop-daemon: warning: failed to kill 2160: No such process
No process in pidfile '/var/run/docker-ssd.pid' found running; none killed.
invoke-rc.d: initscript docker, action "stop" failed.
dpkg: error processing package docker-ce (--remove):
installed docker-ce package pre-removal script subprocess returned error exit status 1
dpkg: error while cleaning up:
installed docker-ce package post-installation script subprocess returned error exit status 1
dpkg: docker-ce-cli: dependency problems, but removing anyway as you requested:
docker-ce depends on docker-ce-cli.
Removing docker-ce-cli (5:20.10.7~3-0~debian-buster) ...
Errors were encountered while processing:
docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
可以看到 invoke-rc.d: could not determine current runlevel ,查看docker-ce.prerm
cd /var/lib/dpkg/info
vim docker-ce.prerm
注释if
if ([ -x "/etc/init.d/docker" ] || [ -e "/etc/init/docker.conf" ]) && \
[ "$1" = remove ]; then invoke-rc.d docker stop || exit $?
fi
重新执行删除
apt remove docker-ce docker-ce-cli docker-ce-rootless-extras
apt purge docker-ce
apt purge docker-ce-cli
apt purge containerd.io
apt autoremove
查看是否有遗漏
apt list --installed | grep docker
apt list --installed | grep containerd.io
删除残留文件
rm -rf /var/lib/docker
rm -rf /var/run/docker
rm -rf /etc/docker
rm -rf /run/docker.sock
rm -rf /var/lib/containerd
rm -rf /run/containerd
rm -rf /opt/containerd
win10利用WSL2安装docker,
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
service docker start
安装后,发现以下错误,
grep: /etc/fstab: No such file or directory
[FAIL] Docker is not running ... failed!
对于/etc/fstab,直接用touch创建即可
touch /etc/fstab
对于后者,可以用下面的解决
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
接着,启动就可以啦
service docker start
测试
# 检查dockerd进程启动
service docker status
ps aux|grep docker
# 检查拉取镜像等正常
docker pull busybox
docker images
docker image ls