Windows: containers fail on a stock WSL2 — Kiri Linux boots a hybrid cgroup tree, so kiri-init exits 1

Open
#277 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, linux, rust

Research direction

Start with crates/kiri-init/src/linux/mod.rs, especially host_cgroup() and mount_cgroup2(), then read contrib/wsl/kiri-linux/wsl.conf and trace how setup starts the WSL engine. Reproduce on stock WSL2 with a hybrid cgroup tree and check whether the chosen fix makes containers start or surfaces the cgroup v2 error clearly. The report also mentions a separate daemon restart issue after WSL shutdown.

Written by the indexing model from the issue text.

Description

Windows: docker run fails on a stock WSL2 — Kiri Linux boots a hybrid cgroup tree and kiri-init exits 1

Kiri version and system

Kiri 0.2.1 (kiri), x64
Windows 10.0.26300.9711 (x64)
WSL 2.4.13.0, kernel 5.15.167.4-microsoft-standard-WSL2
Distro: Kiri Linux (`kiri`), as shipped in the installer

What you did

Installed Kiri-0.2.1-x86_64.msi, let setup run to the end (it selected Kiri Linux, then reported the engine step failing), then:

docker run --rm alpine true

docker pull alpine:latest succeeded; docker run did not. Same with nginx, and setup's own test container failed every time it was retried.

What happened

docker: Error response from daemon: guest stopped before connecting: Some("the agent exited: exit status: 1").

kiri diag logs --errors on the Windows side only shows the wrapper:

ERROR daemon VM did not boot error="guest stopped before connecting: Some(\"the agent exited: exit status: 1\")"
ERROR daemon request failed method=POST path=/containers/create status=500

The actual cause is only in the engine log inside the distro (/var/log/kiri.log, or ~/.kiri/logs/daemon.log in the report):

INFO  daemon kiri-init: Kiri needs cgroup v2 at /sys/fs/cgroup (this machine has cgroup v1 or a hybrid tree there) src=stderr
ERROR daemon VM did not boot error="guest stopped before connecting: Some(\"the agent exited: exit status: 1\")"

And in the distro, right out of the installer:

$ cat /proc/self/cgroup
15:name=systemd:/
...
1:cpuset:/
0::/

$ mount | grep cgroup
tmpfs   on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup  on /sys/fs/cgroup/cpuset  type cgroup (rw,...,cpuset)
cgroup  on /sys/fs/cgroup/cpu     type cgroup (rw,...,cpu)
... (one v1 mount per controller)

$ cat /sys/fs/cgroup/cgroup.controllers
cat: /sys/fs/cgroup/cgroup.controllers: No such file or directory

/etc/wsl.conf is the one from contrib/wsl/kiri-linux/wsl.conf: [boot] systemd = false, with no kernel command line and no boot-time remount.

So host_cgroup() (crates/kiri-init/src/linux/mod.rs:255) sees no cgroup.controllers, calls mount_cgroup2(), finds /sys/fs/cgroup non-empty and returns Err("Kiri needs cgroup v2 at /sys/fs/cgroup ..."). kiri-init exits 1, nothing ever connects, POST /containers/create answers 500.

What you expected instead

docker run --rm alpine true exits 0, as it does on macOS, on a Linux host with a unified tree, and with Docker Desktop on the same machine.

Anything else

kiri diag report --send id: rep_df52faa97cc2d1872eeede2f (sent 2026-11-15, engine log in it covers the whole failure and the fix).

Workaround that works — give WSL a unified cgroup v2 tree, in %USERPROFILE%\.wslconfig:

[wsl2]
kernelCommandLine = cgroup_no_v1=all

then wsl --shutdown. After that, in the same distro, unchanged:

/proc/cmdline                → ... cgroup_no_v1=all
mount | grep cgroup          → cgroup2 on /sys/fs/cgroup type cgroup2
cat /sys/fs/cgroup/cgroup.controllers → cpuset cpu io memory hugetlb pids rdma misc
docker run --rm alpine echo OK                 → OK
docker run -d -p 8080:80 nginx; curl :8080     → HTTP 200

Runtime remount also works, without touching .wslconfig (so this is not a kernel limitation):

umount /sys/fs/cgroup/unified
for c in cpuset cpu cpuacct blkio memory devices freezer net_cls perf_event \
         net_prio hugetlb pids rdma misc; do umount /sys/fs/cgroup/$c; done
mount -t cgroup2 none /sys/fs/cgroup   # cgroup.controllers now exists; kiri-start works

So the fix could live on the Windows side, in one of these places:

  1. During setup / engine start, detect a hybrid tree in the Kiri Linux distro and add kernelCommandLine = cgroup_no_v1=all to .wslconfig (Kiri already reads and writes .wslconfig for memory), then wsl --shutdown and carry on — or
  2. In the distro, as contrib/wsl/kiri-linux/wsl.conf [boot] command, doing the umount/mount above before kiri-start, which keeps it to Kiri's own distro and works on machines where the user already has a .wslconfig, or
  3. At minimum, say so: setup's engine step currently reports the test container as failing with guest stopped before connecting: ... exit status: 1, which sends people to the network/proxy docs (as it did me). Surfacing kiri-init's own line — "needs cgroup v2 at /sys/fs/cgroup (this machine has cgroup v1 or a hybrid tree there)" — in the setup window and in kiri diag logs --errors would name the cause.

A second, smaller thing found while working around it, probably worth its own issue: after wsl --shutdown or wsl --terminate kiri, kiri-win.exe restarts the bridge (bridge exited: Ok(ExitStatus(1)) → bridge started in kiri-win.log) but never starts kiri daemon again in the distro, so every command answers:

error during connect: Get "http://%2F%2F.%2Fpipe%2Fkiri/_ping": No process is on the other end of the pipe.

MSYS_NO_PATHCONV=1 wsl -d kiri -u root -e sh -c '/usr/local/bin/kiri-start', or quitting Kiri from the tray and reopening it, brings it back. The wake path (POST /kiri/wake) can't help, since it needs the daemon that isn't running.

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.