Show HN: Build Your WSL Distro in Docker
48 points
by K0IN
6 days ago
| 6 comments
| github.com
| HN
K0IN
6 days ago
[-]
I love WSL, but I have multiple systems and juggling apt packages is a pain.

So I had this in my head for a long time, that I can just build a rootfs using docker and load it in WSL.

I tried it yesterday, and now I have a CLI tool to build my WSL image using Dockerfiles.

I'm not sure if it helps anyone, but I wanted to share it, just in case.

Cheers.

reply
gavinray
6 days ago
[-]
Could you add this to the README?

I went looking for the "Why?" and couldn't find it, I think others would like to hear this too =)

Best thing I could come up with was "declarative WSL setup like Nix/Fedora Silverblue"

reply
turboponyy
6 days ago
[-]
reply
marmaduke
6 days ago
[-]
This is awesome! I was just today building a new wsl distro, and I didn’t want it tied to just a version of Linux but rather a project. I had to download a rootfs of Ubuntu and import it, and then spent time installing everything. Ofc I could use a bash script to automate the second part.

So this would have solved my prob: have a dockerfile or image and up an wsl env for it. Given how great wsl is these days (i used to have Linux and Mac as daily drivers, now wsl) I guess this sort of thing will become more and more relevant

reply
Rucadi
6 days ago
[-]
Nice tool :) I did something similar in a hackathon some years ago. https://github.com/Rucadi/wsld

It's totally unmaintained and forgotten :D

In general, what I do now to generate WSL images is to docker run a container, and then export it to a .tar, finally, install that tar, is that easy.

However, if I had your tool installed, for sure I would use that for ease of use.

reply
K0IN
6 days ago
[-]
Hei interesting, thanks for sharing.

Also, the idea to do it the other way around WSL -> docker image is really nice.

reply
el_oni
6 days ago
[-]
Very cool, this should help me to be able to separate my different testing environments.

Thanks for sharing!

reply
cckk
4 days ago
[-]
looks cool! Forgive my ignorance, but what's the adv of this over using Docker on WSL2?
reply
K0IN
4 days ago
[-]
for me, the advantages are:

* In WSL2 I don't need to worry about, ports, mounts and data persistence (I think this is possible in docker but it needs more setup work)

* I don't need docker desktop running

in the end I think that both can solve the problem, I myself prefer wsl for my day to day tasks.

reply
tricked
2 days ago
[-]
fyi docker works perfectly fine in wsl on Ubuntu and other distro using the standard installation method on Linux, no docker desktop needed.
reply
pasi1337
6 days ago
[-]
Thats a pretty nice thing to have!

Thanks for sharing this.

reply