top | item 33709443

Install Docker in WSL 2 Without Docker Desktop

60 points| nickjj | 3 years ago |nickjanetakis.com

24 comments

order
[+] tester756|3 years ago|reply
Great news,

Using Docker inside WSL 2 has been painful for years, that's nice to see that things are getting better.

[+] KronisLV|3 years ago|reply
Curiously, WSL2 never worked well for me: for whatever reason the I/O performance was horrible (especially when bind mounting code in PHP containers for local development) and Hyper-V just worked way better. Plus, there was the fact that with Hyper-V I could control the total amount of resources allowed to Docker pretty easily, even if the RAM that was allocated was always taken up while running (dynamic memory allocation in Hyper-V never worked well for me anyways).

Either way, while I'm more than happy with Docker Desktop (my circumstances allow me to use it at no expense), there are also some promising projects out there that some of you might be interested in, provided that you want something more than just the CLI.

Podman Desktop: https://podman-desktop.io/

Rancher Desktop: https://rancherdesktop.io/

[+] boredpudding|3 years ago|reply
Did you have your code within WSL2, or outside of it?

I/O performance is horrible in the second case. It's recommended to have your projects within WSL2. I've personally just bookmarked my projects folder that's within WSL2 so I can access it from Explorer as well.

[+] smileybarry|3 years ago|reply
I wish I could do the opposite, to be honest. I like the Docker Desktop UI and all the command line utilities it auto-installs, but I want to use another Docker host like a VMware Workstation VM or even a remote machine. As of this writing you can just install Docker for Windows and disable a bunch of services + Hyper-V, and the CLI stuff can still work with other machines, but the desktop app just doesn't.
[+] kristianp|3 years ago|reply
What's the advantage of doing this? The drawbacks?
[+] nickjj|3 years ago|reply
The video goes into the pros and cons.

Pros (for not using DD):

    - You use less resources since you don't need a separate DD app running
    - It's more close to the experience you'd have on a production server which wouldn't run DD
Cons (by not using DD):

    - If you like having a UI, you won't have it
    - You can't use Docker extensions if that's something you want
    - You have to install Docker in each WSL 2 instance instead of checking a checkbox in the DD UI
Neutral (in either case):

    - You can still access things on localhost without DD
    - You can still run K8s directly in WSL 2 without DD using Kind and other tools
    - Everything works the same, there's no limitations around Docker's core feature set
    - Performance is really good (including volumes) as long as your files are in WSL 2's file system with or without DD
[+] jslakro|3 years ago|reply
This option is interesting for organizations that cannot afford a monthly license for dozens of developers. Drawbacks... after working a couple of months I can say that time to time there are awful issues that came from nowhere, you need to mantain cleaning things in WSL constantly, so if the company can pay DD avoid the painful way
[+] jollyllama|3 years ago|reply
Nice, I'll take a look. This has been my go-to reference up 'til now https://dev.to/bowmanjd/install-docker-on-windows-wsl-withou...
[+] nickjj|3 years ago|reply
Thanks. I had looked at that reference originally too but it does a lot of things unrelated to running Docker on WSL 2 and overcomplicates running Docker.

Realistically getting Docker to run on WSL 2 involves running a few standard install steps from Docker for installing Docker and Docker Compose v2 on Linux (such as Ubuntu, Debian or whatever distro you prefer) and then adding a 3 line shell script to your ~/.profile to ensure the init.d based Docker service starts when your WSL 2 process starts -- that's it.

I've been running this set up for months, it's super solid.

[+] makeitrain|3 years ago|reply
I was under the impression that docker installed in windows would manage system resources better than inside a wsl commissioner. I use lando, a docker compose wrapper. It’s instructions say to install docker inside wsl, but also warns of stability issues.
[+] jollyllama|3 years ago|reply
Last I checked, Docker desktop in windows requires a license for commercial users, whereas this method doesn't.
[+] larrybud|3 years ago|reply
You can also use docker desktop alternatives on the windows side such as Rancher Desktop or Podman Desktop. Both work similar to Docker desktop in how they integrate with WSL2, but unlike Docker Desktop both are free to use.
[+] throw_me_5555|3 years ago|reply
Strange, for me it mostly worked out of the box, only updating kernel was required. But I had huge issues with networking, VPNs just don't play well with WSL.
[+] maxloh|3 years ago|reply
For anyone only looking for a FOSS solution, Rancher Desktop bundle docker too.
[+] zaps|3 years ago|reply
TALK SLOWER
[+] runjake|3 years ago|reply
Set the playback speed to 0.75x.