Failure to start container with file mounts after windows reboot or wsl restart
Actual Behavior
After a windows or wsl restart:
- The docker container is in state Exit code 127
- Using docker start on the container state that a mounted file (not a folder) is missing. the message clearly show, it tried to mount a folder into a file which cannot work.
- The source folder exist in /mnt/wsl/rancher-desktop/run/docker-mounts/{{some-guid}} and is empty.
Steps to Reproduce
Create a docker-compose file with a file mount. Run docker-compose up. Make sure your container is working. Restart the computer or wsl.
Result
Docker ps -a shows the container with exit code 127 Docker start my-container shows the following error message: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/mnt/wsl/rancher-desktop/run/docker-mounts/1fa63162-7959-421b-a455-17900d2abae2" to rootfs at "/usr/share/opensearch/config/opensearch.yml": mount /mnt/wsl/rancher-desktop/run/docker-mounts/1fa63162-7959-421b-a455-17900d2abae2:/usr/share/opensearch/config/opensearch.yml (via /proc/self/fd/6), flags: 0x5000: 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: opensearch-0
Expected Behavior
Docker ps -a shows a running container
Additional Information
In the error message, /mnt/wsl/rancher-desktop/run/docker-mounts/1fa63162-7959-421b-a455-17900d2abae2 exists as a folder and is not the mounted source file in docker-compose.yml but /usr/share/opensearch/config/opensearch.yml is the correct destination file in the container.
The error doesn't seem to occur when folders are mounted instead of file but that is not always a possible choice.
Rancher Desktop Version
1.8.1 (this bug existed in previous versions)
Rancher Desktop K8s Version
Disabled
Which container engine are you using?
moby (docker cli)
What operating system are you using?
Windows
Operating System / Build Version
Windows 10 21H2 19044.2728
What CPU architecture are you using?
x64
Linux only: what package format did you use to install Rancher Desktop?
None
Windows User Only
N/A
Source: rancher-sandbox/rancher-desktop