Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long working directory in bash when Docker desktop is running in WSL2

I have Docker Desktop running with WSL 2 backend. I also have Ubuntu 20.04 installed as my default WSL2 Linux distro. The problem I am facing is that if I launch C:\Windows\System32\wsl.exe when Docker is running then the shell is initialized with a very long directory path: /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1/mnt/c/Windows/System32

However, if I shutdown docker and start a WSL shell again, then it starts at the expected path: /mnt/c/Windows/System32

I can cd into /mnt/c myself but it is annoying that it doesn't start on the right path. I also tried running wsl -d "Ubuntu-20.04 to no avail. It seems that my C volume is mounted on both /mnt/c and the long ugly path above.

Has anyone experienced and resolved this issue?

Docker Version: 2.3.0.3 (45519)

like image 876
Abdullah Baig Avatar asked Jun 15 '20 19:06

Abdullah Baig


People also ask

How can I tell if Docker is running in WSL2?

To check whether Docker is installed properly or not, check the Docker version using this command docker --version . If you don't get an error like – bash: /usr/bin/docker: No such file or directory and see the Docker version then you know that Docker is installed successfully.

How does Docker Desktop work with WSL2?

Docker Desktop for Windows provides a development environment for building, shipping, and running dockerized apps. By enabling the WSL 2 based engine, you can run both Linux and Windows containers in Docker Desktop on the same machine.

Is Docker Desktop required for WSL2?

No you do not require Docker Desktop to use WSL 2. The only requirements for WSL 2 are that you: Have the right version of Windows installed. Have the Virtual Machine Platform and Windows Subsystem for Linux optional components installed.

How do I move Docker WSL to another drive?

In this approach, we will simply stop the Docker Desktop, move the space-eating directories to another drive having sufficient space, and finally creating symlinks. Step 1 - Stop Docker Desktop. Step 2 - Relocate the existing directories %USERPROFILE%\AppData\Local\Docker and C:\ProgramData\Docker to new directories.


1 Answers

It seems to work okay if I start Docker desktop first and then WSL.

like image 73
Abdullah Baig Avatar answered Oct 20 '22 23:10

Abdullah Baig