docker, windows
📝 This article is a translation of the original Japanese post. View original
The command 'docker' could not be found in this WSL 2 distro Even Though WSL2 Is Configured in Docker Desktop
On Ubuntu under WSL2, I was getting:
1$ docker build (git)-[main]
2
3The command 'docker' could not be found in this WSL 2 distro.
4We recommend to activate the WSL integration in Docker Desktop settings.
5
6For details about using Docker Desktop with WSL 2, visit:
7
8https://docs.docker.com/go/wsl2/
Of course I had already followed Docker Desktop WSL 2 backend on Windows | Docker Docs.
Running the wsl command from the command prompt:
1C:\Users\am>wsl.exe -l -v
2 NAME STATE VERSION
3* Ubuntu Running 2
4 docker-desktop Stopped 2
5 docker-desktop-data Stopped 2
What is this “Stopped”? I wondered — maybe Docker Desktop also boots a WSL2 VM?
1# after starting docker desktop
2
3C:\Users\am>wsl.exe -l -v
4 NAME STATE VERSION
5* Ubuntu Running 2
6 docker-desktop Running 2
7 docker-desktop-data Running 2
Now they are Running. Let’s run the docker command in WSL2.
1$ docker images (git)-[main]
2REPOSITORY TAG IMAGE ID CREATED SIZE
3hubproxy.docker.internal:5555/docker/desktop-kubernetes kubernetes-v1.28.2-cni-v1.3.0-critools-v1.28.0-cri-dockerd-v0.3.4-1-debian 1d7e8203bdb9 3 weeks ago 430MB
Well, obviously.
To summarize:
- Unless Docker Desktop is started, the docker-desktop VM on WSL2 is not running
- As a result, even though the docker command should be runnable, you get the error
The command 'docker' could not be found in this WSL 2 distro