Skip to content

Graceful shutdown of any systemd distro unmounts shared /mnt/wsl mounts in ALL distros (breaks Docker Desktop WSL integration VM-wide) #41084

Description

@sh41

Windows Version

Microsoft Windows [Version 10.0.26200.8875]

WSL Version

2.7.10.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

Linux version 6.18.33.2-microsoft-standard-WSL2 (root@f1bbfb02316b) (gcc (GCC) 13.2.0, GNU ld (GNU Binutils) 2.41) #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026

Distro Version

Ubuntu 24.04 & 26.04

Other Software

Docker Desktop (Windows): Version 4.82.0 (233772)

Repro Steps

  1. Start Docker Desktop with WSL integration enabled for distro A (e.g. Ubuntu-24.04). Verify in A:
$ findmnt /mnt/wsl/docker-desktop/cli-tools
/mnt/wsl/docker-desktop/cli-tools /dev/loop0 iso9660 ro,relatime,...
$ docker --version
Docker version 29.6.1, ...
  1. Start any other systemd-enabled distro B, then terminate it:
wsl --terminate B
  1. (WSL's idle auto-termination of B would also trigger this. No explicit terminate needed.)
  2. In distro A (and in docker-desktop itself): /mnt/wsl/docker-desktop/cli-tools is gone, /dev/loop0 is detached, docker is broken. Docker Desktop's UI still reports everything healthy; its backend log shows nothing.

VM kernel log (dmesg from docker-desktop) at the moment of failure — distro B (ec3ed5cb... = its root ext4) shutting down, immediately followed by the shared mounts dying VM-wide:

[1951.663026] Exception: Operation canceled @p9io.cpp:258 (AcceptAsync)
[1957.137509] systemd-journald[43]: Received SIGTERM from PID 1 (systemd-shutdow).
[1957.337165] EXT4-fs (sdh): unmounting filesystem ec3ed5cb-9466-40be-810a-a5223fd6cd3f.

After this instant: losetup -a inside docker-desktop shows loop0 (docker-wsl-cli.iso) detached; findmnt /mnt/wsl/docker-desktop/cli-tools fails in every distro. The Docker engine itself is untouched (its data disk /dev/sde stays mounted; running containers keep running), only the shared-mount state is destroyed.

Mount propagation state (all distros):

$ grep '/mnt/wsl ' /proc/self/mountinfo
359 367 0:34 / /mnt/wsl rw,relatime shared:1 - tmpfs none rw
$ grep cli-tools /proc/self/mountinfo
978 359 7:0 / /mnt/wsl/docker-desktop/cli-tools ro,relatime shared:568 - iso9660 /dev/loop0 ...

shared:* peer groups spanning all distros are probably why one distro's umount reaches every other one.

When a read of the ISO is in flight during the event, the kernel additionally logs I/O error, dev loop0, sector ... op READ etc. Just noise from the original umount.

Expected Behavior

Terminating/shutting down one distro should not remove shared mounts in other distros.

Actual Behavior

Terminating/shutting down one distro removes shared mounts in other distros.

Diagnostic Logs

Emailed

Workaround

A per-distro systemd unit that flips /mnt/wsl to slave propagation only at shutdown, so the dying distro's unmounts stop propagating outward:

# /etc/systemd/system/wsl-mnt-guard.service
[Unit]
Description=Protect shared /mnt/wsl mounts from shutdown unmount propagation

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecStop=/bin/sh -c "mount --make-rslave /mnt/wsl 2>/dev/null || true"

[Install]
WantedBy=multi-user.target

With this enabled in the systemd distros, the repro above no longer breaks anything: cli-tools stays mounted everywhere across distro terminations. Runtime propagation must stay shared. Docker Desktop relies on distro to VM propagation for its bind-mount publishing, which is why the fix happens only in ExecStop.

Possibly linked to:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions