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

Aperta
#277 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
docker, linux, rust

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
7.5k
Fork
329
Merge medio
7h 48m
PR unite (30g)
105

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di libracoder/kiri

Tutte le issue di libracoder/kiri

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.