Exactly the same problem as Ubuntu WSL with docker could not be found
$ docker
The command 'docker' could not be found in this WSL 1 distro.
We recommend to convert this distro to WSL 2 and activate
the WSL integration in Docker Desktop settings.
See https://docs.docker.com/docker-for-windows/wsl/ for details.
But my requirement is different — I want to
- stick with WSL1 (for reasons beyond this topic)
- and use Docker for Windows as-is
I.e., I have WSL1 and Docker for Windows installed parallel to each other. This is my current info:
C:> ver
Microsoft Windows [Version 10.0.18363.1379]
C:> wsl -l -v
NAME STATE VERSION
* Debian Running 1
I don’t see integration in "Resources -> WSL Integration", and I don’t have WSL2 backend enabled in Docker Desktop settings.
Just that I’m getting the above problem — my docker
works anywhere, in CMD, Powershell, git-bash, etc, just not in my WSL.
All solutions that I found are to install Docker for Windows within WSL1 or WSL2, but I want to keep everything as is — WSL and Docker for Windows installed parallel to each other.
Any solution for that?
3
Answers
Just FTA, this is the quick hacky workaround that I found, while trying to solve it myself
Change the
C:Program FilesDockerDockerresourcesbindocker
file toThen
docker
can work anywhere now, inCMD
,Powershell
,git-bash
, and as well asWSL1
.Note that this hacky workaround is specially for the situation described in OP, might not work for anything else.
This means in
WSL2
, it has a real linux kernel which is required to install docker daemon, then indocker-desktop
you could have chance to set docker daemon inWSL2
. Otherwise, the docker daemon is running inHyper-V machine
. But, if you stick inWSL1
, no chance to rundocker-daemon
in WSL, so the only option is runningdocker daemon
inHyper-V machine
.Although above is the fact, still we have chance to let you operate
docker ps, docker pull
etc. inWSL1
bash just like you operate throughCMD, Powershell, git-bash
, that is allow Docker to accept requests from remote hosts.For your case, the steps maybe next:
1. Expose docker daemon in
docker desktop
settings as next, then clickApply & Restart
:2. Install standalone docker client in
WSL1
:3. Set default docker daemon:
4. Verify docker client command:
I ran into the same issue with Ubuntu 20 Distro when trying to use Docker. Below are steps I followed to resolve it:
1- I went to microsoft Store and downloaded a recent distro version of the distro, that was Ubuntu 22.04
2- On powershell as admin, I ran the command
wsl -l -v
to make sure I have the new version3- I ran the command: wsl –set-default Ubuntu-22.04 to use wsl 2
I was now able to use Docker on WSL 2