Hacker News new | past | comments | ask | show | jobs | submit login
Install Docker in WSL 2 Without Docker Desktop (nickjanetakis.com)
60 points by nickjj on Nov 22, 2022 | hide | past | favorite | 24 comments



Great news,

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


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/


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.


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.


What's the advantage of doing this? The drawbacks?


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


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


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...


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.


thats basically what I do... I didn't even realize there was the 'service' thing till a few months ago. Login, start the daemon, and go :-)


Does this method still require hyper-v?


If you can run WSL 2 then you can use this method.

I personally run Windows 10 Pro which does have Hyper-V enabled (I use Hyper-V for standalone VMs unrelated to Docker) so I can't disable it to check for you but I'd say I'm 99.99% sure it'll work without Hyper-V because this is focused on running an application (Docker) inside of a WSL 2 environment. If WSL 2 is available to run then Docker can run in it because WSL 2 is providing the Linux environment. There is no separate VM running Docker.

Try it out and let us know.


WSL2 definitely works on Windows 10 Home, which doesn't have Hyper-V. My understanding is that they split off the VM functionality needed for WSL2 into the "Virtual Machine Platform" feature so that pro+ is no longer required.


That's the important question really. If it still requires a vm, then there is almost no difference between methods.


Where I really need docker, I also need VMware workstation more. It’s been a limiting factor for me. Was asking to ensure this wasn’t some trickery but sounds promising. I already have WSL working just didn’t think to try docker in that layer!


VMware and hyper-v have both worked on the same machine for some time now. since v15 or v14.


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.


Last I checked, Docker desktop in windows requires a license for commercial users, whereas this method doesn't.


Docker Desktop requires a license for commercial users no matter which platform you use it on.

the Docker daemon and Docker CLI are open source and are free, even on Windows.


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.


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.


For anyone only looking for a FOSS solution, Rancher Desktop bundle docker too.


TALK SLOWER


Set the playback speed to 0.75x.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: