Docker and WSL

Card Puncher Data Processing

About

Both your own WSL 2 distro and docker-desktop run on the same utility VM.

They share the same Kernel, VFS cache etc. They just run in separate namespaces so that they have the illusion of running totally independently.

The code should be in the default Linux distribution for the best development experience using Docker and WSL 2.

Your project files should be stored within your WSL 2 distro of choice, you should run the docker CLI from this distro, and you should avoid accessing files stored on the Windows host as much as possible.

Folders Distro

Docker creates two distro folders to store data:

  • \\wsl$\docker-desktop
  • \\wsl$\docker-desktop-data

To see these folders, replace <distro name> with the name of your distribution (ie. Ubuntu-20.04)

\\wsl$\<distro name>\mnt\wsl
\\wsl$\Ubuntu-20.04\mnt\wsl

Docker Wsl Distro Folders File Explorer

Support

docker: Got permission denied

You may got a permission denied when running a docker command in WSL.

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=dokuWsl: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

That's because you don't have enough permission and the easiest way to solve this problem is to run you command with sudo

Documentation / Reference







Share this page:
Follow us:
Task Runner