Hacker News new | ask | show | jobs
by arsfeld 1756 days ago
How would that work if you're using WSL? Docker for Desktop uses WSL but creates it's own separate VM (if you can call it a VM).

Would I be able to install and run Docker inside Ubuntu's WSL distro to avoid paying for Docker for Desktop?

6 comments

Yes, but you'd have to connect the Docker CLI running in Windows to the engine inside Ubuntu (not hard), and then you wouldn't be able to mount stuff in Windows into Docker containers via relative paths (you'd have to start them with /mnt/c/...). If neither of those things matter for you (like if all of your project code is inside your WSL VM), then it's totally fine.
I do all my work under WSL, and run Docker engine in WSL and it works perfectly. 100% headless.

I may have had to expose the Docker socket for VS Code containers support to work, but that wasn't any pain, and secured with TLS.

Never needed Docker Desktop, which seemed like a bloated mess.

You can connect to a remote Docker engine instance over SSH, which is easier to setup than exposing the Docker socket over a TCP port.

So install the client inside WSL and the engine on a Linux VM.

EDIT: https://raesene.github.io/blog/2018/11/11/Docker-18-09-SSH/ was a blog I wrote when that feature landed, AFAIK it works the same way now :)

Or just use it inside WSL2, which already is a Linux VM?
I've never actually tried installing Docker engine in WSL2... might work I guess :)
Enable WSL2, then you can just install the docker provided by your distro package manager. For example, I am using docker packaed by Arch Linux, and it works as expected.

If you need to use `docker` command under Powershell, maybe exposing docker socket to Windows host would probably work. I didn't try it as I don't need it.

You could configure Docker Engine in Ubuntu to expose a network socket, and configure Docker CLI in Windows WSL to use that network socket: https://wiki.archlinux.org/title/Docker#Daemon_socket
You probably can, there's nothing about containers that shouldn't work on WSL2