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

Failure to start container with file mounts after windows reboot or wsl restart #4286

Open
kds-jprat opened this issue Mar 27, 2023 · 7 comments
Labels
area/volume Access to host volumes from inside the VM or containers kind/bug Something isn't working platform/windows

Comments

@kds-jprat
Copy link

kds-jprat commented Mar 27, 2023

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

@kds-jprat kds-jprat added the kind/bug Something isn't working label Mar 27, 2023
@kds-jprat kds-jprat changed the title Failure to start container after windows reboot or wsl restart Failure to start container with file mounts after windows reboot or wsl restart Mar 27, 2023
@kds-jprat
Copy link
Author

Just adding a few details from docker inspect:
Mounts:
image
Volumes:
image

@kds-jprat
Copy link
Author

kds-jprat commented Apr 28, 2023

I ended up finding something funny.

  • If I use docker run -v from windows cmd,
    • At first, it mounts the volume correctly, I see the actual path i passed in the commands in the mount list when inspecting (volume list is nil).
    • At wsl/windows restart, i have the problem above, all the path are replaced by those /docker-mounts/guid (and the volume list is filled with information) and the container will not start.
  • If i use docker run -v from wsl,
    • From the get go, It does not mount the volume and I endup with a problem similar as above immediately: It replaces my path with /docker-mounts/guid folders in the mounts list. (however the volume list is nil)

something changes the mounts paths and modifies the volume list and breaks everything. And mount folders from wsl docker command also breaks folder mounts, not just files.

@kds-jprat
Copy link
Author

Is there any news about this ? any idea about when this will be checked on the roadmap ?

@lystor
Copy link

lystor commented Sep 13, 2023

Also Rancher desktop doesn't remount volumes on container restart:

$ powershell

# wsl

# docker version
Client:
 Version:           24.0.6-rd

Server:
 Engine:
  Version:          23.0.6

# cd /mnt/c/temp/

# cat <<EOF > hello.py
import os, time

for i in range(5):
    print(i)
    print(os.listdir('/app/'))
    time.sleep(1)

print('DONE')

EOF

# docker run -d -it \
    --restart=unless-stopped \
    --name=bug \
    -v /mnt/c/temp/:/app/ \
    python:3.11.5-bookworm \
    python /app/hello.py

# docker exec -it bug ls /app/
hello.py

# sleep 10

# docker logs bug
0
['1.txt', 'hello.py']
1
['1.txt', 'hello.py']
2
['1.txt', 'hello.py']
3
['1.txt', 'hello.py']
4
DONE
python: can't open file '/app/hello.py': [Errno 2] No such file or directory
python: can't open file '/app/hello.py': [Errno 2] No such file or directory
python: can't open file '/app/hello.py': [Errno 2] No such file or directory
python: can't open file '/app/hello.py': [Errno 2] No such file or directory

# docker ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED          STATUS                          PORTS     NAMES
077d72de9862   python:3.11.5-bookworm          "python /app/hello.py"   45 seconds ago   Restarting (2) 10 seconds ago             bug

# docker rm -f bug

Tested on 1.9.1 / 1.10 with WSL2.

@kds-jprat
Copy link
Author

Perhaps we should regroup all these bugs together, there are so many duplicates of this now.

@ggirard07
Copy link

Same issue here when trying to open an existing repo with a devcontainer in Rancher Desktop instead of Docker Desktop.

@ahosker
Copy link

ahosker commented Jan 9, 2024

This just started randomly, not opened the container in a month. Not sure what I have changed (if anything).

@mook-as mook-as added the area/volume Access to host volumes from inside the VM or containers label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/volume Access to host volumes from inside the VM or containers kind/bug Something isn't working platform/windows
Projects
None yet
Development

No branches or pull requests

6 participants