Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Docker in WSL 2

Tips and Traps

  1. Docker on WSL 2 works great. However, the performance of IO is extremely bad if it access the Windows filesystem. For more discussions, please refer to WSL 2 Filesystem .

  2. Docker containers launched from a WSL (e.g., Ubuntu) shell will continue to run after the WSL shell is terminated, as long as the Docker daemon is alive. As a matter of fact, a WSL 2 shell is not must to start the Docker daemon (back by WSL 2) or to launch Docker containers.

Install Docker in WSL 2

  1. Install WSL 2 following instructions in Tips on WSL 2 .

  2. Install in WSL 2.

    sudo apt-get install
  3. Install Docker desktop for Windows.

  4. Set Docker to use WSL 2 based engine.

    1. Open Docker desktop settings.
    2. Check the checkbox "Use the WSL 2 based engine" in the general tab.
    3. Click "Apply & Restart".


For more details, please refer to Docker Desktop WSL 2 backend .