Windows: expose the engine socket to other WSL distros (WSL integration)

Open
#269 2 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, linux, rust

Research direction

Start by reading the referenced docs/features.md section on TCP half-close and the existing kiri-start and kiri setup --docker-socket entry points. The report describes the desired mount, socket permissions, distro selection and optional Docker context, but does not identify implementation files or settle the settings and security design. Done would mean opt-in WSL distro integration survives shutdown and daemon restarts and supports the demonstrated Docker CLI and Compose workflows.

Written by the indexing model from the issue text.

Description

enhancement
What you're trying to do

I develop inside my own WSL2 distro (NixOS; the same goes for Ubuntu and others), and I need the docker CLI and Compose there, with Linux paths for bind mounts.

On Windows, Kiri's Docker API can only be reached from Windows (npipe:////./pipe/kiri). The daemon serves /var/lib/kiri-daemon/.kiri/run/docker.sock inside the kiri distro only, and TCP is deliberately not offered (the half-close issue in docs/features.md), so another distro has no way to reach the engine. Running docker.exe through interop doesn't help, because bind mounts get Windows paths. This is what keeps me on Docker Desktop today.

What you'd like Kiri to do

Docker Desktop handles this with "WSL integration": you pick the distros in Settings, and each one gets the engine's socket.

All WSL2 distros share one kernel and the /mnt/wsl tmpfs, so a unix socket bind-mounted there is reachable from every distro, without touching the network. I tested this by hand:

# in the kiri distro, as root
mkdir -p /mnt/wsl/kiri
mount --bind /var/lib/kiri-daemon/.kiri/run /mnt/wsl/kiri
chgrp 1000 /mnt/wsl/kiri/docker.sock && chmod 660 /mnt/wsl/kiri/docker.sock   # 1000 = docker group in my distro

# in another distro, as a regular user in that group
export DOCKER_HOST=unix:///mnt/wsl/kiri/docker.sock
docker run --rm alpine echo hello              # prints hello
echo piped | docker run --rm -i alpine cat     # prints piped (stdin + half-close work)
docker run -d --name from-nixos alpine sleep 3600   # shows up in Kiri's window and in `docker --context kiri ps` on Windows

Tested with Kiri 0.2.1 and docker CLI 29.9.2 on kernel 6.18.58.1-microsoft-standard-WSL2.

I can't make this stick myself: the mount is lost on wsl --shutdown, the kiri distro is managed by Kiri, and kiri-start recreates the socket, so its group and mode reset whenever the daemon restarts.

Proposal:

  • Settings → "WSL integration": an opt-in list of the user's distros, off by default.
  • When it's enabled, kiri-start binds the run dir to /mnt/wsl/kiri/, and the daemon creates the socket as 0660 with a fixed group. That's the same model as the kiri group on Linux ("root-equivalent, exactly like the docker group").
  • Optionally, in each enabled distro, create a kiri docker context, or (opt-in) point /var/run/docker.sock at it, as kiri setup --docker-socket does on macOS.

Security: the kiri distro stays as locked down as it is now (interop off). This opens no way into that distro beyond the Docker API. It does give container-level root to anyone in the socket's group in any distro of the same WSL VM. Docker Desktop's WSL integration draws the same trust boundary, which is why this should be opt-in.

Would you like to build it?

No, just suggesting it

Dominant language
Rust
Stars
7.5k
Forks
329
Avg merge
7h 48m
Merged PRs (30d)
105

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libracoder/kiri

All issues in libracoder/kiri

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.