- Because when you run docker desktop for Windows, it will be creating two WSL instances behind the scenes anyway. This will take up more resources than this method.
- Docker desktop attempts to inject the docker commands into your existing WSL instance. It does this through a series of hacks that frankly are just complex and prone to breakage.
- Bind mounts are from Linux to Linux. When you run Docker Desktop on Windows, you are bind mounting from the Windows filesystem to a Linux system. This can make things like hot reloading web frameworks not work very well. (this is because it can't recieve filesystem events when you save the files)
Because it's exactly like running docker on a native linux machine.
You won't have access to the Docker Desktop UI. But you can use something like portainer if you absolutely need a UI. I personally just use the CLI. You should too.
First, make sure you have WSL installed and the distro you want to run setup and configured.
We first must turn on systemd. This is supported by editing the /etc/wsl.conf file and adding the following lines:
[boot]
systemd=true
One you edit this and save it, you will need to restart your wsl instance. A common way to do this is to run
wsl --shutdown
from a powershell.
When you open WSL back up, if you do a ps aux
command you should see all the system processes like you would on a normal linux server.
Next you want to install "Docker Engine" for Linux. Follow the instructions here for whatever Linux distro you are running:
https://docs.docker.com/engine/install/
That's it, this works now exactly like docker on a regular Linux server.
- Make sure you follow the instructions to allow your normal user to execute docker commands, otherwise you'll always have to use docker as root.
- The docker install script (if you use it), will complain about running in WSL and really wants you to use docker desktop. Ignore it, we know better than Docker.