179

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.

Not able to change to WSL2 and not able to install docker:

docker wls

4
  • 1
    Did you apt install docker within your WSL environment? You're going to need to install full docker for your windows OS, and then install the docker CLI tool within your WSL environment, pointing WSL's docker at your host machine's docker port. This should help: nickjanetakis.com/blog/… Commented Aug 20, 2020 at 3:53
  • 2
    I get the same error occationally. The problem always solves itself after I go to docker desktop and press the update button. Maybe that helps somone. Commented Mar 3, 2022 at 10:48
  • I needed this because everything in my container's bash executed really slowly. So in my case I had open "Ubuntu for Windows" and execute explorer.exe . which opened a network folder in which I had to copy all my projects from "c:\dev" ie. from Windows filesystem. After that nothing worked, and Fabrício's answer saved the day. Then in Ubuntu for Windows I executed cd dev/gitlab.mycompany.com/my-project/sub-project and then code . opened WSL version of my project in VS Code. Rebuilt docker containers and everything now works smoothly. Commented Mar 24, 2022 at 10:05
  • Often the problem that leads me to this Google Search is very simple: I forget to start Docker Desktop :) Commented Apr 12, 2023 at 10:04

25 Answers 25

297

You need to go to the docker desktop settings, and enable integration with your distro in "Resources -> WSL Integration".

enter image description here

7 Comments

Only worked after installing wsl_update_x64.msi. See step 3 here docs.docker.com/docker-for-windows/wsl/#prerequisites
I do not have the WSL Integration on my Docker Desktop app, Do I have to upgrade the Docker desktop to get the WSL Integration feature?
@pushStack I have the same problem. I installed both WSL 2 and Docker desktop the date of this posting and it still refuses to appear.
This may be obvious to others, but in addition to the Fedora/Ubuntu/XXX Linux distro you choose, Docker will also install/create WSL distros docker-desktop and docker-desktop-data. You might need to run & 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon in PowerShell. I had to "SwitchDaemon"s twice, the first time to enable me to go to Docker Desktop settings, but it didn't show the WSL integration. So I ran "SwitchDaemon" again, and it was willing to show WSL integration. I had to go through this because of some irritating system update.
Had to do this before mine started working: Open Docker Desktop and click on the 'troubleshoot' icon in the top right corner. Click 'Clean/Purge Data' and select 'WSL 2' only and click 'delete'. Restart docker. docker-desktop-data was Stopped before that.
|
122

Assuming you already have wsl 2 in your system, run powershell as admin:

run wsl --list --verbose which will give you a list of your wsl running processes:

> wsl --list --verbose
  NAME                   STATE           VERSION
  Ubuntu-20.04           Running         1

Then to switch it with wsl --set-version <your proc> 2:

> wsl --set-version Ubuntu-20.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

2 Comments

If you have multiple versions, you may also want to set it as your default distro version: wsl --set-default Ubuntu-20.04
This works for me Only after restarting the computer.
106

My problem seems like it's the same, despite the integration WSL is already enabled since installation.

In the windows shell:

> wsl docker --version

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

See https://docs.docker.com/docker-for-windows/wsl/ for details.

An option to resolve this problem is reinstalling Docker Desktop (https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon#how-to-uninstall-docker), but don't need to do this.

The steps below work for me (I found at https://github.com/docker/for-win/issues/7039).

Open windows shell (maybe as admin), and run:

> wsl -t docker-desktop
> wsl --shutdown
> wsl --unregister docker-desktop

Then go to windows services, stop the Docker Desktop Service, OR to do this running the command in windows shell as admin:

> Stop-Service -Name "com.docker.service"

And finally, restart the Docker Desktop App.

Test in the windows shell:

> wsl docker --version
Docker version 20.10.2, build 2291f61

9 Comments

I had to right-click the docker icon (system taskbar) and select Restart Docker...
I keep finding a factory reset on docker desktop is the only thing that works
This works for me too, but I have to do that almost every day. Does anyone else experience that?
There is no restart menu item when I right click on the blue whale. However, there is a restart in the bug (troubleshoot) icon. But restarting doesn't work for me.
This worked for me. I just needed to ensure the Docker Desktop app actually restarted, since it didn't for some reason. Thanks for the solve.
|
22

I stuck with this error after remove Ubuntu 18.04 and install the 20.04.

Even with the WSL 2 enabled, I still face this error.

This is what works for me, go the Settings --> resource and toggle the "Ubuntu" then the error disappear :)

enter image description here

1 Comment

Surprised have to enable an extra Ubuntu flag when in General section already enabled the "Use the WSL 2 based engine". But solved the problem!
16

For me running the following command in wsl terminal worked:

sudo apt-get update
apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo apt-get install docker-compose
sudo apt-get upgrade

Source: https://www.srcmake.com/home/fabric

1 Comment

"Package 'docker-ce' has no installation candidate"
14

For me, nothing worked excepted : right click on running Docker icon (next to clock) and chose "Switch to Linux containers"

enter image description here

And here we go ! Now i can have the menu Settings > Resources > WSL integration.

1 Comment

This is the resolution to those who can't see the "WSL Integration" option under "Resources" in Settings
9

WSL Integration under Resources was not showing for me.

I had to uncheck "Use the WSL2 based engine" under General settings, Apply, then Check it again, Apply, then WSL Integration showed up under resources and I could click the Ubuntu slider.

Comments

7

For those still having issues with this, some of my symlinks magically vanished and no amount of reinstalling helped.

Make sure you have the following symlinks in your WSL2 installation:

$ ls -l /usr/bin/ | grep docker
lrwxrwxrwx 1 root   root          56 Jul 14 13:01 com.docker.cli -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/com.docker.cli
lrwxrwxrwx 1 root   root          48 Jul 14 13:01 docker -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker
lrwxrwxrwx 1 root   root          56 Jul 14 13:01 docker-compose -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose
lrwxrwxrwx 1 root   root          59 Jul 14 13:01 docker-compose-v1 -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose-v1
lrwxrwxrwx 1 root   root          71 Jul 14 13:01 docker-credential-desktop.exe -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-credential-desktop.exe
lrwxrwxrwx 1 root   root          50 Jul 14 13:01 hub-tool -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/hub-tool
lrwxrwxrwx 1 root   root          48 Jun 29 09:27 notary -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/notary

2 Comments

Any idea on why/how this happens? I don't think my setup had symbolic links under /usr/bin but its obviously a work-around. I read through the docker (not docker.exe) file /mnt/c/Program Files/.... and it is a shell script that checks /usr/bin for docker
No idea. Sorry. I just found the above missing symlinks and it fixed it.
7

I had this issue, for me running

$ ls -l /usr/bin/ | grep docker

showed all the correct symlinks as per this answer however I saw the following:

which docker
/mnt/c/Program Files/Docker/Docker/resources/bin/docker

The fix was to simply to set the PATH variable to have /user/bin as the first entry

PATH="/usr/bin:$PATH"

From the multitude of answers, it seems like there are many things that can cause this error, so your mileage may vary.


Another good thing to check is that Docker Desktop is actually running. If it isn't, which docker will result in the /mnt/c/... directory as above.

Comments

5

In my case, the integration was correctly set in the docker-app, WSL2 was correctly the default wsl, and I wasn't able to solve unregistering the wsl docker instance and restarting the docker service like mentioned in other answers.

After some time, I noticed that the command docker-compose successfully worked. The issue was limited to the docker command.

I looked for all docker commands in the directory usr/bin, that is the path where docker-compose is located (which docker-compose), so runnining ls -l /usr/bin | grep docker, I found

drwxrwxrwx  1 root   root          48 Nov 29 10:59 docker
lrwxrwxrwx  1 root   root          56 Nov 29 10:59 docker-compose -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose*
lrwxrwxrwx  1 root   root          59 Nov 29 10:59 docker-compose-v1 -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose-v1*
lrwxrwxrwx  1 root   root          71 Nov 29 10:59 docker-credential-desktop.exe -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-credential-desktop.exe*
lrwxrwxrwx  1 root   root          50 Nov 29 10:59 hub-tool -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/hub-tool*

For some weird reason, docker wasn't a symbolic link but a directory.

I solved removing the directory and re-creating manually the symbolic link:

rm -rf /usr/bin/docker
sudo ln -s /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker /usr/bin/docker

1 Comment

Great it help, also met next problem with exec com.docker.cli executable file not found in $path which could be solve with alternative command addresing to cli com.docker.cli sudo ln -s /mnt/wsl/docker-desktop/cli-tools/usr/bin/com.docker.cli /usr/bin/docker
4

As Taylor wrote in his comment you need to connect from WSL to docker desktop.
In the image you attached there is a check box expose daemon on ... Check this box.
Now you need docker cli, you can install Linux vm then install docker in that Linux vm you just installed.
Then run which docker and copy this file to your windows computer.
Copy the docker executable into /usr/local/bin on your WSL.
Now run the following in WSL

echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc
. ~/.bashrc

This worked for me on WSL 1.

Here is guide I found on the all process

Comments

3

I followed theses steps: https://learn.microsoft.com/en-us/windows/wsl/install-win10

Also, for docker into ubuntu, I enabled it in docker resources as a final step. Settings > Resources > WSL Integration. from: https://docs.docker.com/docker-for-windows/wsl/

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference
3

Fabrício Pereiras answer was working for me, but I had to do it pretty often, which was still annoying. Turns out the order of starting the systems is important too.

Start Docker first, then WSL2 after.

I don't start Docker Desktop with Windows and usually had opened a terminal in WSL already. Then Docker could not be found. Fabricios answer was working for me because I shutdown WSL2, then started it again when Docker was already running.

1 Comment

This is exactly what I do however came here to find another solution if I am running wsl and can not restart for docker? is there any?
2

Make sure that you have a distro that is compatible with wsl2:

https://ubuntu.com/wsl

enter image description here

Comments

2

I was experiencing the same issue with Ubuntu-20.04 (WSL2) and Docker Desktop (v4.11.1). For me, WSL integration and other flags are all set but still I was getting:

The command 'docker' could not be found in this WSL 2 distro.

I followed @r590 's method. I turned-off and then turned-on WSL Integration under:

Resources > WSL Integration

and then it worked for me.

Comments

2

I rebooted my machine and docker stopped working. I reinstalled docker-desktop and did all the suggestions and nothing worked.

I found that I had a directory here /usr/bin/docker. I deleted it and then reinstalled docker which fixed the issue.

Comments

1

Sometimes the simplest solution is the most effective solution, if you are installing docker desktop for the first time make sure you restart windows for the effects to take change. This is not guaranteed to work but it is always worth a shot.

Comments

1

The error shows that you're using WSL version 1.

To change it to 2, open PowerShell and run

wsl -l -v

WSL versions

You should see a number 1 near Ubuntu (or something similar).

To change that to version to 2, simply run

wsl --set-version Ubuntu 2

and you'll see something like

Conversion in progress from wsl1 to wsl2

1 Comment

this is the exact first steps regarding issue "The command 'docker-compose' 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." within Ubuntu Box when you try docker command like "docker-compose up -d httpd php" and then you will get the Ubuntu option to enable under Docker->Resources->WSL integration.
1

I had the same problem The error:

The command 'docker' could not be found in this WSL 2 distro. We recommend to activate the WSL integration in Docker Desktop settings.

The solution: Upgrading the desktop-docker version

  1. If updates are available, When you navigate to the Docker Dashboard, you will be able to click on Download Updates as shown below.

enter image description here

  1. enter image description here

  2. enter image description here

1 Comment

Hi, please add supporting informations. Also,, please read Why should I not upload images of code/data/errors?. Thank you
0

I was having the same issue, however, for me, I installed docker using a different Windows account (admin) because my default account (under a domain) is a standard user and has no admin access.

After installing docker, I started docker and got an error that I'm not part of the docker-users group so I started docker using the admin account that I have. Docker started but it's not able to see the WSL integration. Similar to the screenshot below.

Docker config missing WSL integration

What fixed it for me is to add the domain account to the docker-users and restart my machine. After that WSL is visible in the configuration.

# For local account
net localgroup docker-users "your-user-id" /ADD

# For domain account
net localgroup docker-users "DOMAIN\your-user-id" /ADD

Docker config showing the WSL integration

1 Comment

The commands can only be executed using Admin rights. And typically, after installation the user is already part of the localgroup... This doesn't work for me. I only get the error after the PC is woken after standby.
0

In WSL2 I've installed the docker service, using these instructions: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository.

So in my WSL2 Ubuntu environment I have the docker service running. I have no need for the desktop interface, the docker instances are containers for services.

It works generally, but often I forget to 'sudo start service docker' (I need to upgrade my linux sysadmin skills to get the service to start properly with the instantiation of WSL2 environment)

(FWIW: This really should simply be a comment, but I lack the requisite qualifications at the moment...)

Comments

0

This reply is from Superdooperhero and solved my problem using docker-compose in WSL2 distro.

Specs: OS: Windows 11 22H2 Distro: Ubuntu 22.04 LTS with WSL2

Error:"The command 'docker-compose' 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/"

Solution: Had to do this before mine started working: Open Docker Desktop and click on the 'troubleshoot' icon in the top right corner. Click 'Clean/Purge Data' and select 'WSL 2' only and click 'delete'. Restart docker. docker-desktop-data was Stopped before that.

Comments

0
  1. Inside docker desktop GUI enable connection over tcp and copy url. It should look somthing like: tcp://localhost:2375 setting ui selection screenshot

  2. install docker on wsl 1.

  3. if you notice, wsl somehow intercepts you calling docker so you need to invoke the full path which docker. For me it was /usr/bin/docker. Be sure to export DOCKER_HOST=tcp://localhost:2375

export DOCKER_HOST=tcp://localhost:2375
/usr/bin/docker build . -t jkarasev/nvim:1.0

wsl docker working screenshot

Comments

-1

Switch to linux containers in docker desktop then it will work.

Comments

-2

You need to run the WSL console as Admin. If not, the docker command may be not recognized.

1 Comment

There is no case that I can think of where running WSL as Admin is the correct solution. Running WSL as Admin has security implications, and should typically be avoided unless you absolutely need to access some resource in Windows with elevated permissions. But in doing so, you give any code running as your WSL user full access to your Windows host, including modification and removal of system-level files. sudo/root aren't even needed to modify (or corrupt) your Windows installation when running WSL elevated.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.