Docker Community Forums

Share and learn in the Docker community.

How do you create a bind mount in Docker when running with the WSL2 backend?

I tried

  • /mnt/d/s/elasticsearch
  • /mnt/host/d/s/elasticsearch
  • /host_mnt/d/s/elasticsearch

to point to D:\s\elasticsearch but all my attempts are yielding path not found.

Note I only have docker installed, no other WSL Distribution is installed.

The mount points with WSL are in /run/desktop/mnt/host/<drivename> so to mount d:/s/elasticsearch use

docker run --rm -v /run/desktop/mnt/host/d/s/elasticsearch:/mnt alpine ls /mnt

Ensure you have completed the steps described in the Prerequisites section before installing the Docker Desktop Stable release.

Follow the usual installation instructions to install Docker Desktop. If you are running a supported system, Docker Desktop prompts you to enable WSL 2 during installation. Read the information displayed on the screen and enable WSL 2 to continue.
Start Docker Desktop from the Windows Start menu.
From the Docker menu, select Settings > General.

Enable WSL 2

Select the Use WSL 2 based engine check box.

If you have installed Docker Desktop on a system that supports WSL 2, this option will be enabled by default.

Click Apply & Restart.
Ensure the distribution runs in WSL 2 mode. WSL can run distributions in both v1 or v2 mode.

To check the WSL mode, run

wsl -l -v

To upgrade your existing Linux distro to v2, run:

wsl --set-version (distro name) 2

To set v2 as the default version for future installations, run:

wsl --set-default-version 2

When Docker Desktop restarts, go to Settings > Resources > WSL Integration.

WSL Integration will be enabled on your default WSL distribution. To change your default WSL distro, run wsl --set-default .

For example, to set Ubuntu as your default WSL distro, run wsl --set-default ubuntu.

Optionally, select any additional distributions you would like to enable WSL 2 on.

WSL 2 Choose Linux distro

Click Apply & Restart.