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
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?
Use docker for windows in WSL1 (!) note: this applies only to WSL1. In WSL2 you can install docker and be happy — just use the official way of installing. Expose the docker client api without tls (there is a setting in Docker Desktop to do that) Now docker ps should already work. Install docker-compose and go for it.
Run Docker for Windows in “mixed” mode by running Windows and Linux containers together. I recently learned that I could turn on experimentally features in Docker for Windows and run both Windows and Linux images simultaneously. Normally we need to switch between them, and you can run one or the other.
First, VirtualBox 6 has an 'experimental' support for Hyper‑V. Second, the upcoming Windows Subsystem for Linux version 2 fully supports docker using Hyper‑V, even on Windows Home edition. Windows Subsystem for Linux (WSL) is really great for developers who want to install Windows on their PC.
The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon.
With a couple of tweaks the WSL (Windows Subsystem for Linux, also known as Bash for Windows) can be used with Docker for Windows. Quick Jump: Configure Docker for Windows (Docker Desktop) | Install Docker and Docker Compose within WSL | Configure WSL to Connect to Docker for Windows | Ensure Volume Mounts Work This post only applies to WSL 1!
Otherwise, the docker daemon is running in Hyper-V machine. But, if you stick in WSL1, no chance to run docker-daemon in WSL, so the only option is running docker daemon in Hyper-V machine.
To do this, select Settings from the menu and activate WSL2 backend engine on the General tab. After applying these actions, you will need to reboot the Docker application and then confirm the activation of WSL integration for Docker Desktop.
Install 🔗 Follow the usual installation instructions to install Docker Desktop. If you are running a supported system, Docker... Start Docker Desktop from the Windows Start menu. From the Docker menu, select Settings > General. Select the Use WSL 2 based engine check box. If you have installed ...
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.
This means in WSL2
, it has a real linux kernel which is required to install docker daemon, then in docker-desktop
you could have chance to set docker daemon in WSL2
. Otherwise, the docker daemon is running in Hyper-V machine
. But, if you stick in WSL1
, no chance to run docker-daemon
in WSL, so the only option is running docker daemon
in Hyper-V machine
.
Although above is the fact, still we have chance to let you operate docker ps, docker pull
etc. in WSL1
bash just like you operate through CMD, 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 click Apply & Restart
:
2. Install standalone docker client in WSL1
:
$ wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.5.tgz
$ tar zxvf docker-20.10.5.tgz
$ cd docker
3. Set default docker daemon:
$ export DOCKER_HOST=tcp://localhost:2375
4. Verify docker client command:
$ ./docker info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With