问题描述 (Problem Description):
Docker Desktop某一天打开报错, 无法使用docker了
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
$ root@-PC:/mnt/c/Users/ Lyu# uname -r
6.6.36.3-microsoft-standard-WSL2
$ root@-PC:/mnt/c/Users/Lyu# cat /etc/issue
Ubuntu 22.04.4 LTS \n \l
docker目前版本:
# ls -lh |grep deb
-rw-r--r-- 1 root root 30M Jul 25 11:04 containerd.io_1.7.19-1_amd64.deb
-rwxr--r-- 1 root root 29M Jul 25 11:06 docker-buildx-plugin_0.16.1-1~ubuntu.22.04~jammy_amd64.deb
-rwxr--r-- 1 root root 14M Jul 25 11:06 docker-ce-cli_27.1.1-1~ubuntu.22.04~jammy_amd64.deb
-rwxr--r-- 1 root root 8.9M Jul 25 11:06 docker-ce-rootless-extras_27.1.1-1~ubuntu.22.04~jammy_amd64.deb
-rwxr--r-- 1 root root 12M Jul 25 11:07 docker-compose-plugin_2.29.1-1~ubuntu.22.04~jammy_amd64.deb
-rwxr--r-- 1 root root 90M May 24 18:28 google-chrome-stable_114.0.5735.90-1_amd64.deb
# docker --version
Docker version 27.1.1, build 6312585
# docker info
xxxxx
错误消息 (Error Messages):
running wsl distro proxy in Ubuntu-22.04 distro:exit status 1
在 Ubuntu-22.04 发行版中运行 wsl 发行版代理:退出状态 1
问题的根本原因 (Root Cause):
未知
解决方案 (Solution):
在WSL中,
systemd
并不作为默认的初始化系统运行,因此你无法使用systemctl
命令来管理Docker服务。在WSL环境下,Docker通常需要通过其他方法来管理。所以通常是在Windows上运行的,而不是直接在WSL中运行。你可以在Windows中安装Docker Desktop,这会设置Docker守护进程,并允许WSL与之进行通信。
无效方案A: 卸载安装最新版的docker, 没有用
风险: 可能会丢失原本的镜像
有效方案B: 升级Ubuntu版本
WSL版本升级: 到Ubuntu24.04后, 可以解决
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble
有效方案C: 从APT源列表中去掉Docker源并恢复到不使用Docker源的状态
sudo rm /etc/apt/sources.list.d/docker.list
sudo apt update
和sudo apt upgrade
, 然后再sudo apt dist-upgrade
.
然后重新打开桌面版docker:
总结
问题解决:
测试Docker功能:
- 验证Docker连接: 运行以下命令来验证Docker CLI是否能正常工作:
docker info
- 运行测试容器:
docker run hello-world
# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:1408fec50309afee38f3535383f5b09419e6dc0925bc69891e79d84cc4cdcec6
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d2c94e258dcb 14 months ago 13.3kB
很棒! 又又又又可以开始继续使用了~