20

According to Docker documentation, using Docker under WSL v2 should be fairly simple:

  1. Install WSL 2 (make sure all the preconditions are met);
  2. Install Docker Desktop 2.2.0 or newer;
  3. In Docker Settings > General enable 'Expose daemon on tcp://localhost:2375 without TLS' and 'Enable the experimental WSL 2 based engine';
  4. Make sure no Docker-related packages are installed in your Linux file system.

Once all this is done, I should be able to run docker or docker-compose commands from my Linux Terminal. But I'm not. I keep getting Command 'docker' not found, but can be installed with sudo apt install docker.io'.

What am I doing wrong?

4 Answers 4

25

Did you check if the integration is enabled in Resources > WSL Integration as below?

Docker Desktop Settings Snapshot

For more details see: Get started with Docker remote containers on WSL 2

Sign up to request clarification or add additional context in comments.

3 Comments

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. Link-only answers can become invalid if the linked page changes. - From Review
@Chris It's actually a link to the Stack imgur where the answerer uploaded their image, so it's not in danger of going away as long as Stack is here. That said, the graphic should have at least been included inline, but that's a simple edit.
My config is like the image above but still getting 'docker-compose' could not be found in this WSL 2 distro.
11

I just used docker-compose.exe up in a WSL2 Ubuntu terminal and it worked. The .exe extension is basically needed in WSL2 to run a Windows executable.

1 Comment

an Awesome answer
2

Have you made sure that wsl2 is enabled for your distro? Run this in Powershell

wsl -l -v

If your distro is not on WSL 2 then enable it like this.

wsl --set-version <Distro> 2

1 Comment

I'm having the same problem, and yes, my distro runs version 2. Daemon is exposed, WSL2 in docker is checked... Still, I'm getting the same error message
2
  1. Install docker and docker-compose.
  2. Type in the terminal:

    sudo service docker start
    sudo service --status-all | grep '+'
    

3 Comments

You have typos and/or formatting issues: stackoverflow.com/editing-help
I consider this a code-only answer. Please help fighting the misconception that StackOverflow is a platform for finding unpaid programmers. To do so please add an explanation of how this works and why it helps.
This doesn’t work on WSL2, as the system has not been booted with a regular systemd daemon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.