nerdctl: Unable to mount volumes or bind mount on Windows
Issue:
When using nerdctl + containerd on Windows, I am unable to mount volumes or bind mount to a new windows container. I’ve tried using the following command with no success:
PS C:\Users\Administrator\nerdctl\_output> nerdctl.exe --debug-full run -d -v C:\bind_volumes\v1:c:\src hello-world:nanoserver-1809
time="2022-01-30T02:04:37-08:00" level=debug msg="verification process skipped"
time="2022-01-30T02:04:37-08:00" level=debug msg="Calling proc (1)" spanID=7599fa456674789d traceID=6d976231e769a37073cadb49b4a21362
time="2022-01-30T02:04:37-08:00" level=debug msg="Calling proc (2)" spanID=7599fa456674789d traceID=6d976231e769a37073cadb49b4a21362
time="2022-01-30T02:04:37-08:00" level=fatal msg="failed to parse \"C:\\\\bind_volumes\\\\v1:c:\\\\src\""
I’ve also tried experimenting with the the -v
option, by trying various ways of single/double quoting an escaping special characters, but again I did not have any success.
Code Investigation:
Now, I do not know how to program in Go (so please excuse me if I’m totally wrong here). But starting at line 56 in mountutil.go, it looks like that whole switch statement is really only designed to handle Linux paths. I say this because on line 56, the value passed to -v
is being split on the “:” character and the switch statement doesn’t look like it would be able to handle bind mount (eg: -v c:\hostDir:c:\guestDir
) or just mounting volumes to a windows container (eg: -v vol1:c:\guestDir
).
Also, line 56’s parent function (generateMountOpts), returns back up to run_mount.go on line 195. Just a few lines below that on line 203, it looks like the SecureJoin may encounter issues if a full windows path containing a colon character were to be joined with tempDir on that line.
That’s what I’ve been able to observe to the best of my ability. If I’m overthinking or if I’ve made some very obvious mistake when trying to use the -v
option, please let me know.
Thanks!
My Environment:
- OS: Windows Server 2019
- OS Version: 1809 (OS Build 17763.1282)
- CPU arch: Intel x86-64
- nerdctl version: v0.16.0
- containerd version v1.5.9
- Other information:
- Is the Windows Container feature enabled: Yes
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (6 by maintainers)
I would like to make a PR to fix this
I am running nerdctl from gitbash on Windows machine and this command is working for me:
nerdctl run -v c\:/folder/anotherfolder:/build/somefolder <image_id> ls build/somefolder
@wtfacoconut There is a bug in containerd for different drive letters in Windows: https://github.com/containerd/containerd/issues/6589. Once that is fixed and this parsing error here is fixed, we would be able to support the other driver letters
Use instead: -v /bind_volumes/v1:/src For me in Windows it works using Linux paths style.