Thank you all for the quick responses. I am going to try and give as much information as possible from what I gathered so far trying to debug this:
- This problem is not inherent to just files, it’s also folder- so really mounting anything. I have read that when you try to mount a file (or folder) to the countainer and docker does not find the original file (or folder) to mount, it silently mounts it as a directory, an empty directory.
Some evidence pertaining to this:
a. Trying to mount my run.py file (a copy of which is already in the image when building from the Dockerfile), I get the error message:
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime creat
e failed: runc create failed: unable to start container process: error during container init: error mounting "/home/ha
jerkr/unity/fw-gears/fw-volumetrics/run.py" to rootfs at "/flywheel/v0/run.py": mount /home/hajerkr/unity/fw-gears/fw-
volumetrics/run.py:/flywheel/v0/run.py (via /proc/self/fd/7), 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.
b. Trying to mount a config.json (which is not already in the image): It silently mounts it as a directory:
hajerkr@KCL54ML264:~/unity/fw-gears/fw-volumetrics$ docker run -it --rm --entrypoint bash -v /home/hajerkr/unity/fw-gears/fw-volumetrics/config.json:/flywheel/v0/config.json flywheel/volumetrics:0.0
.6
root@6f78974dda88:/flywheel/v0# ls
README.md app config.json manifest.json requirements.txt run.py utils
root@6f78974dda88:/flywheel/v0# ls -l
total 24
-rwxr-xr-x 1 root root 2901 Oct 22 15:49 README.md
drwxr-xr-x 2 root root 4096 Oct 22 15:49 app
drwxr-xr-x 2 root root 40 Oct 24 15:46 config.json
-rwxr-xr-x 1 root root 3360 Oct 24 15:44 manifest.json
-rwxr-xr-x 1 root root 2666 Oct 24 15:51 requirements.txt
-rwxr-xr-x 1 root root 2377 Oct 24 15:33 run.py
drwxr-xr-x 2 root root 4096 Oct 22 15:49 utils
root@6f78974dda88:/flywheel/v0#
c. Trying to mount a folder in which there is a csv file, it mounts it a folder (great), but it’s empty, meaning it probably again did not find it in the first place and silently mounted it as an empty directory with that name.
The only time I get an error message is when I try to mount a file of which a copy is already in the container, because that’s the only time it sees a clash (“are you trying to mount a file onto a directory or vice versa” … In this case it tries to mount the run.py (interpreted as a folder potentially for visibility problems described above) onto a file.
Now I have no idea why it does this. I didn’t have this issue when working from a Mac. So I feel like there might be a layer there coming between filesystems docker tries to access, wsl etc … ? But this happens as well when trying to mount from /mnt/c , hence why moved my data to my WSL filesystem.
I hope this gives more context, and I hope you don’t hit a wall like I did.
In terms of inspecting the container, this is the mount block, it’s using a relative path for some reason although I mount using the full path in my command, unsure if that’s expected / it infers the relative path or something is awry :
"Mounts": [
{
"Type": "volume",
"Name": "config.json",
"Source": "./config.json",
"Destination": "/flywheel/v0/config.json",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
],
@rimelek you can find the github repo for the image here GitHub - Nialljb/fw-VoluMetrics . The config.json is something I create after so feel free to make a dummy file.
I tried your proposed solutions of mounting testfile to /testfile, nothing appears actually. When I try mounting it to /flywheel/v0, it is again an empty directory.
EDIT: For more context, my machine is SOE managed by my uni, but I have admin rights, which I needed to install Docker etc. Is it possible that this may be a rights issue? I ran the same command with sudo
but it didn’t make a difference.
Thanks a lot for your help