Skip to content

How to Fix Docker WSL2 Integration Error

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Docker WSL2 Integration Error. We cover key concepts, practical examples, and best practices.

Docker commands from WSL2 return Cannot connect to the Docker daemon or Docker Desktop shows WSL2 integration not enabled — Docker Desktop cannot communicate with your WSL2 distribution.

The Problem

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?

Or Docker Desktop shows a warning that WSL2 integration is not working.

Step-by-Step Fix

Step 1: Verify WSL2 is installed and set as default

wsl --status

Expected:

Default Distribution: Ubuntu
Default Version: 2

If not, set WSL2 as default:

wsl --set-default-version 2

Step 2: Enable WSL2 integration in Docker Desktop

  1. Open Docker Desktop → Settings → Resources → WSL Integration
  2. Ensure "Enable integration with my default WSL distro" is checked
  3. Select your WSL distro (Ubuntu, Debian, etc.)
  4. Apply & Restart

Step 3: Restart Docker Desktop

# From PowerShell as admin
Restart-Service docker

Or restart Docker Desktop from the system tray.

Step 4: Verify from WSL2

Open your WSL2 terminal:

docker ps

Expected:

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

Step 5: Check the Docker socket in WSL2

ls -la /var/run/docker.sock

Expected:

srwxrwxr-x 1 root docker 0 ... /var/run/docker.sock

Step 6: Check Docker context

docker context ls

Ensure the active context is default (not a remote context).

Prevention Tips

  • Enable WSL2 integration in Docker Desktop settings before using Docker from WSL
  • Keep Docker Desktop and WSL2 updated
  • Use the same WSL distro consistently for Docker work
  • Restart Docker Desktop after WSL2 updates
  • Do not install Docker Engine inside WSL2 when using Docker Desktop

Common Mistakes with wsl error

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world DOCKER code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Should I install Docker Engine inside WSL2 or use Docker Desktop?

Use Docker Desktop with WSL2 integration. This avoids running a second Docker daemon inside WSL2 and gives you the GUI, resource management, and Kubernetes support. Installing Docker Engine inside WSL2 is only needed for remote servers.

Why does docker ps work but docker compose does not?

Docker Compose may not be installed in your WSL2 distro. Install it with sudo apt install docker-compose-plugin or use the Docker Desktop bundled version from the host.

How do I enable WSL2 integration for a non-default distro?

In Docker Desktop → Settings → Resources → WSL Integration, toggle on the specific distro. The distro must be set to WSL2 mode (wsl --set-version <distro> 2) and must be running (wsl -d <distro>).

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro