Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

The docker command is missing inside your WSL Ubuntu

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

Short answer

Docker Desktop only adds the docker command to a WSL distro when integration is enabled for that distro. Check that the distro runs WSL 2, that Docker is in Linux containers mode, and that your distro is ticked under Settings, Resources, WSL integration. After changing it, run wsl --shutdown and open the distro again.

  • Applies to Windows 11, Docker Desktop 4.x, WSL 2, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run this in PowerShell on Windows, not inside Ubuntu. It shows which distros exist and which WSL version each one uses.

    wsl.exe -l -v
  2. 2Match what you see, then jump to its fix

    1. 1The VERSION column of wsl -l -v shows 1 for your UbuntuThe distro runs WSL 1Fix
    2. 2docker works in PowerShell but not in the Ubuntu shellWSL integration is not enabled for this distroFix
    3. 3The WSL integration page is missing from Settings, ResourcesDocker Desktop is in Windows containers modeFix
    4. 4Integration is ticked and the distro is WSL 2, but the command is still unknownWSL was already running when Docker Desktop was installedFix

What does the error look like?

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

Cause 1 of 4

The distro runs WSL 1

1Check

Docker Desktop integration with WSL requires a distro that uses WSL 2. The list command prints the version per distro.

wsl.exe -l -v

2Fix

Convert the distro to WSL 2. Microsoft warns the conversion can take a while and can fail on large projects, so back up important files first.

wsl.exe --set-version Ubuntu-24.04 2

3Verify

The VERSION column now shows 2.

wsl.exe -l -v

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 4

WSL integration is not enabled for this distro

1Check

In Docker Desktop open Settings, Resources, WSL integration. Docker enables integration for the default distro only; every other distro has to be ticked by hand.

wsl.exe --status
wsl.exe -l -v

2Fix

Tick your distro under WSL integration and click Apply. To make Ubuntu the default instead, set it as default first.

wsl.exe --set-default Ubuntu-24.04

3Verify

Open a new Ubuntu shell and ask for the client version.

docker version

Confirmed by docs.docker.com

Did this fix it?

Cause 3 of 4

Docker Desktop is in Windows containers mode

1Check

Run this in PowerShell. The Docker documentation says that if WSL integrations is not available under Resources, Docker may be in Windows container mode.

docker version --format '{{.Server.Os}}'

2Fix

Right-click the Docker icon in the taskbar tray and choose Switch to Linux containers. Then enable integration for your distro as above.

# Docker Desktop tray menu: Switch to Linux containers

3Verify

The server OS now reads linux.

docker version --format '{{.Server.Os}}'

Confirmed by docs.docker.com

Did this fix it?

Cause 4 of 4

WSL was already running when Docker Desktop was installed

1Check

The Docker docs say that for the Docker VMM setup, a WSL that was already running at install time must be restarted so the distros pick up the updated Windows PATH. An older Docker Engine installed inside the distro must also be removed before Docker Desktop.

wsl.exe -l -v

2Fix

Stop every distro and the WSL virtual machine, then open Ubuntu again.

wsl.exe --shutdown

3Verify

The docker command now resolves.

command -v docker && docker version

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Keep WSL up to date with wsl.exe --update; Docker Desktop lists a minimum WSL version.
  • Do not install Docker Engine inside the distro when you use Docker Desktop; the Docker docs ask you to uninstall it first.
  • After installing a new distro, open Docker Desktop settings and tick it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

A dev container port does not open in the browser when Docker runs on a remote host

If your application only accepts calls from localhost, it will reject connections from published ports

Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.