Volume mount won't remount across docker restart in WSL2
See original GitHub issueEDIT May 25, 2022
Further testing shows that this bug occurs with any volume mount from a native WSL2 directory, not just ones that have soft links to a Windows directory, as described below. If you mount a WSL2 directory as a volume in a Docker container, it stops working once Rancher is restarted. If you mount a Windows directory as a volume in a Docker container, it will still work after Rancher is restarted.
Actual Behavior
A volume mount which uses a soft link to mount a directory in Windows works OK when container is first run, but does not remount when the container is stopped then restarted.
Mounting a Windows volume in a Docker container doesn’t work when specifying the volume’s path as /mnt/c/Users/...
but does work if you soft link from the WSL2 home directory. Unfortunately the container cannot remount the volume after stopping and restarting it.
Steps to Reproduce
$ pwd
/home/xxx
$ ls -lat win
lrwxrwxrwx 1 xxx xxx 46 Apr 21 19:55 win -> '/mnt/c/Users/xxx/projects/'
$ sudo -E /usr/local/bin/docker run -itd --restart=always -v /home/xxx/win:/home/xxx/work -v /var/run/docker.sock:/var/run/docker.sock linux-dev --hostname linux-dev --name linux-dev
93dc4d62eae20d5de72e8cab1b0db51c1fc188c6c4577db8a4b876cff9a7dc97
$ docker stop linux-dev
linux-dev
$ docker start linux-dev
Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/mnt/wsl/rancher-desktop/run/docker-mounts/aaad516c-8005-484e-be16-b6a867acf089" to rootfs at "/var/run/docker.sock" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Error: failed to start containers: linux-dev
Result
$ docker start linux-dev Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting “/mnt/wsl/rancher-desktop/run/docker-mounts/aaad516c-8005-484e-be16-b6a867acf089” to rootfs at “/var/run/docker.sock” caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type Error: failed to start containers: linux-dev
Expected Behavior
Container starts with volume mount intact.
Additional Information
No response
Rancher Desktop Version
1.3.0
Rancher Desktop K8s Version
n/a
Which container runtime are you using?
moby (docker cli)
What operating system are you using?
Windows
Operating System / Build Version
OS Name Microsoft Windows 10 Enterprise Version 10.0.19042 Build 19042
What CPU architecture are you using?
x64
Linux only: what package format did you use to install Rancher Desktop?
No response
Windows User Only
No
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:8 (1 by maintainers)
I am experiencing the same bug using bind mounts in docker-compose through WSL2.
Upon further review - I think everything is working correctly - but the issue we are running into is due to mungeContainersStartRequest doing a look-up against the full container id which is stored in
docker-binds.json
If I perform a
docker start e14f944aedfebf7ce2dfba98ae13450767a2a58dc50d8a87f5e02ac1b5fb7429
the container comes up with the correct bind mounts - however using any other alias (ie the name or short id) is not found in the map and therefore the binds are not re-created.