How to run docker-compose under WSL 2

Viewed 28572

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?

3 Answers

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

Docker Desktop Settings Snapshot

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. Install docker and docker-compose.
  2. Type in the terminal:

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