The command 'docker' could not be found in this WSL 2 distro. — Docker Desktop is
installed, but its WSL integration is not enabled for the distribution you are in. Switch it on
for that distribution under Settings, Resources, WSL integration, and docker inside
WSL talks to the same engine you use from Windows.
The message does not come from Linux. A small Docker script prints it, found through the Windows
PATH that WSL appends to yours. If you cannot change the setting right now,
docker.exe works from the same shell.
The error
PS> wsl -d Ubuntu-24.04 -- docker ps
The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.
For details about using Docker Desktop with WSL 2, visit:
https://docs.docker.com/go/wsl2/
The exit code is 1, and every subcommand prints the same text, docker compose version
included. docker-compose gets its own copy with its name in the first line.
Why it happens
With no Linux Docker client installed, the shell finds Docker Desktop's Windows folder on the PATH:
$ type -a docker
docker is /mnt/c/Program Files/Docker/Docker/resources/bin/docker
$ ls -l /usr/bin/docker /usr/local/bin/docker
ls: cannot access '/usr/bin/docker': No such file or directory
ls: cannot access '/usr/local/bin/docker': No such file or directory
That docker file is a short sh script. Under a WSL 2 kernel it runs
/usr/bin/docker when that file exists, which is where its own comment says the
integration puts the real client, and otherwise prints the message above and exits. Under Git
Bash the same script hands over to docker.exe. So the message means exactly one
thing: this distribution has no Linux docker client yet.
The fix
In Docker Desktop open Settings, then Resources, then WSL integration. "Enable integration with my
default WSL distro" covers the distribution marked with * in
wsl -l -v; for any other, switch on its toggle under "Enable integration with
additional distros" (the "Refetch distros" button picks up a new one), then apply the change.
Open a new WSL shell and run docker version.
Until then, the Windows client works through WSL interop:
$ docker.exe run --rm --name fix5-wsl alpine echo hello from WSL
hello from WSL
That is the Windows client, and it does not see the distribution's folders: a bind mount of the default user's home folder, which exists in Ubuntu-24.04, failed with "bind source path does not exist". Use it for quick checks and turn the integration on before you mount project files. The other route is installing Docker Engine inside the distribution, which gives it its own client but also runs a second, separate engine with its own images and containers. Choose it only if you do not want Docker Desktop.
How it was reproduced
On Windows 11 with WSL 2.7.10 (kernel 6.18.33.2), the Ubuntu-24.04 distribution (Ubuntu 24.04.4
LTS) and Docker Desktop 4.95.0 with engine 29.8.2. The integration was not active for
Ubuntu-24.04, so running docker there reproduced the message as is. The setting
labels were read from Docker Desktop's own interface files and the setting was left off, so the
integration fix itself was not run on this PC; the docker.exe workaround was, and
printed its greeting. fix5-wsl is the test container's name.
Frequently asked
- Why is docker not found in WSL 2 when Docker Desktop is installed?
- Docker Desktop's WSL integration is off for that distribution, so there is no Linux docker client in it. The message comes from a Docker script on the Windows PATH that WSL appends to the Linux one.
- How do I enable Docker Desktop WSL integration for Ubuntu?
- In Docker Desktop go to Settings, Resources, WSL integration. Tick Enable integration with my default WSL distro if Ubuntu is your default, or switch on Ubuntu under Enable integration with additional distros, then apply and open a new shell.
- Can I use Docker in WSL without the Docker Desktop integration?
- Yes, call docker.exe from the WSL shell; it is the Windows client and talks to the same engine. Installing Docker Engine inside the distribution also works but runs a second, separate engine.
More decoded errors in the Fixes category. How the engine, the client and WSL fit together on a Windows PC: What Docker Desktop Actually Runs on Windows.