Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker containers fail to unmount volumes with nested mounts on WSL2 #8250

Closed
bcxpro opened this issue Feb 18, 2025 · 1 comment · Fixed by #8251
Closed

Docker containers fail to unmount volumes with nested mounts on WSL2 #8250

bcxpro opened this issue Feb 18, 2025 · 1 comment · Fixed by #8251
Labels
kind/bug Something isn't working

Comments

@bcxpro
Copy link
Contributor

bcxpro commented Feb 18, 2025

Actual Behavior

When executing Docker CLI on WSL2, containers that mount volumes with nested mounts fail to unmount them after running, resulting in a "device or resource busy" error. This happens specifically with directories that have nested mounts inside them (like /lib/modules on WSL2).

Steps to Reproduce

  1. Run Docker client on with WSL2
  2. Execute a simple Docker command that mounts a volume with nested mounts, such as:
    docker run --rm --volume /lib/modules:/lib/modules alpine ls /lib/modules

repro-nested-mounts.txt

Alternatively, use the attached script repro-nested-mounts.sh which creates a reproducible test case

To use the attached script:

chmod +x repro-nested-mounts.sh
sudo ./repro-nested-mounts.sh

Result

Error message similar to:

docker: Error response from daemon: failed to modify the response from the backend: munger failed for /containers/706d9ae2589c9d182688bffb9231de545ab82dc51185ff25813ce18c2a89b8d3/start: could not unmount bind mount /mnt/wsl/rancher-desktop/run/docker-mounts/6efe3666-a5cc-42b2-8ddd-5dc326a49ff3: device or resource busy.

The unmount operation fails because the nested mounts within the volume cannot be properly unmounted.

Expected Behavior

Docker should correctly unmount all volumes after container execution, regardless of whether they contain nested mounts. The command should complete successfully without any errors about unmounting or busy devices.

Additional Information

This issue occurs specifically with nested mounts. A nested mount is when a directory already has other filesystems mounted within it, and then that parent directory is bind-mounted into a container.

I've attached a test script (repro-nested-mounts.sh) that reliably reproduces this issue by:

  1. Creating tmpfs mounts at /tmp/<GUID>/outer and /tmp/<GUID>/outer/inner
  2. Binding the outer mount to a Docker container
  3. Running a docker container that mounts /tmp/<GUID>/outer
  4. Attempting to clean up all mounts when done

Rancher Desktop Version

1.17.0

Rancher Desktop K8s Version

N/A

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 11

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

No response

@bcxpro
Copy link
Contributor Author

bcxpro commented Feb 18, 2025

I have created PR #8251 with a possible solution for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant