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

Unable to mount volumes or bind mount on Windows #759

Closed
MikeTheSnowman opened this issue Jan 30, 2022 · 16 comments
Closed

Unable to mount volumes or bind mount on Windows #759

MikeTheSnowman opened this issue Jan 30, 2022 · 16 comments
Labels
enhancement New feature or request platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)

Comments

@MikeTheSnowman
Copy link

MikeTheSnowman commented Jan 30, 2022

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
@AkihiroSuda AkihiroSuda added platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2) enhancement New feature or request labels Jan 30, 2022
@Zheaoli
Copy link
Member

Zheaoli commented Feb 8, 2022

I would like to make a PR to fix this

@jsturtevant
Copy link
Contributor

I would like to make a PR to fix this

Thanks for taking a look!

@textminer
Copy link

Use instead: -v /bind_volumes/v1:/src
For me in Windows it works using Linux paths style.

@jsturtevant
Copy link
Contributor

for reference docker does work with the c:\:

docker run -it -v c:\temp:C:\temp k8s.gcr.io/e2e-test-images/busybox:1.29-2 cmd
Microsoft Windows [Version 10.0.17763.2114]                                                                                                                                                    (c) 2018 Microsoft Corporation. All rights reserved.

C:\>dir
 Volume in drive C has no label.
 Volume Serial Number is 5C49-4D09

 Directory of C:\

08/25/2021  05:31 AM    <DIR>          bin
08/25/2021  05:31 AM    <DIR>          curl
08/25/2021  05:31 AM    <DIR>          dig
08/05/2021  11:08 AM             5,510 License.txt
08/25/2021  05:31 AM    <DIR>          Program Files
03/09/2022  08:48 AM    <DIR>          temp
08/25/2021  05:31 AM    <DIR>          tmp
03/09/2022  08:51 AM    <DIR>          Users
03/09/2022  08:51 AM    <DIR>          Windows
               1 File(s)          5,510 bytes
               8 Dir(s)  21,294,342,144 bytes free

C:\>cd temp

C:\temp>

@MikeTheSnowman
Copy link
Author

I am unable to mount volumes or bind mount to a new windows container. I've tried using the following command with no success:

Hey @textminer, if I use this approach, do you have a recommendation on how to target different windows drive letters? For example, if I wanted to bind-mount "f:\foo\bar", how would I accomplish this using nerdctl?

@jsturtevant
Copy link
Contributor

@wtfacoconut There is a bug in containerd for different drive letters in Windows: containerd/containerd#6589. Once that is fixed and this parsing error here is fixed, we would be able to support the other driver letters

@MikeTheSnowman
Copy link
Author

@wtfacoconut There is a bug in containerd for different drive letters in Windows: containerd/containerd#6589. Once that is fixed and this parsing error here is fixed, we would be able to support the other driver letters

Understood. Thanks for the info.

@junnplus
Copy link
Member

@wtfacoconut There is a bug in containerd for different drive letters in Windows: containerd/containerd#6589. Once that is fixed and this parsing error here is fixed, we would be able to support the other driver letters

Looks like containerd/containerd#6589 fixed by containerd v1.6.6 (PR containerd/containerd#6651)

@kkbruce
Copy link

kkbruce commented Jul 22, 2022

PS C:\> containerd.exe -v
containerd github.com/containerd/containerd v1.6.6 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1

PS C:\> nerdctl.exe -v
nerdctl version 0.21.0

Get "failed to parse" error message:

PS C:\> nerdctl.exe --debug-full run -it -v C:\tools\:c:\tools --rm --name test mcr.microsoft.com/windows/nanoserver:ltsc2022
time="2022-07-22T08:55:21Z" level=debug msg="verification process skipped"
time="2022-07-22T08:55:21Z" level=debug msg="Calling proc (1)" spanID=0fbc95fd368421cb traceID=751b7e5859dbdbba7510ddbf9c44f373
time="2022-07-22T08:55:21Z" level=debug msg="Calling proc (2)" spanID=0fbc95fd368421cb traceID=751b7e5859dbdbba7510ddbf9c44f373
time="2022-07-22T08:55:21Z" level=fatal msg="failed to parse \"C:\\\\tools\\\\:c:\\\\tools\""

@jsturtevant
Copy link
Contributor

@kkbruce this won't work, there is a patch in progress at #924

work around is to use /path/ without the drive : #759 (comment)

@kkbruce
Copy link

kkbruce commented Jul 25, 2022

@jsturtevant @textminer

I've been trying for a long time and can't come up with the alternatives you mentioned. Can you provide a complete run description of the -v or -mount parameters?

Local c:\\data folder:

PS C:\> dir .\data\

    Directory: C:\data

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         7/25/2022   3:36 PM              8 test.txt

Test mount function:

PS D:\> nerdctl.exe run -it --rm -v "/data/:c:\Windows\Temp" mcr.microsoft.com/windows/servercore:ltsc2022
time="2022-07-25T15:49:09+08:00" level=warning msg="expected an absolute path, got a relative path \"/data/\" (allowed for nerdctl, but disallowed for Docker, so unrecommended)"
time="2022-07-25T15:49:09+08:00" level=fatal msg="expected an absolute path, got \"c\""

PS D:\> nerdctl.exe run -it --rm -v "/data/:/Windows/Temp" mcr.microsoft.com/windows/servercore:ltsc2022
time="2022-07-25T15:49:23+08:00" level=warning msg="expected an absolute path, got a relative path \"/data/\" (allowed for nerdctl, but disallowed for Docker, so unrecommended)"
time="2022-07-25T15:49:23+08:00" level=fatal msg="expected an absolute path, got \"/Windows/Temp\""

@ablackrain
Copy link

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

@jfb0101
Copy link

jfb0101 commented Aug 18, 2023

Any progress on this? I've tried a lot of combinations of path specification. Nothing works.

@Suzamax
Copy link

Suzamax commented Oct 11, 2023

Same problem there. I tried in all possible ways but I have to deal with Docker CE yet. Any ETA regarding this issue, or which version will have a fix available?

Thanks!

@Choquito29
Copy link

Any updates ? Thanks

@apostasie
Copy link
Contributor

@AkihiroSuda this is apparently fixed by #2661 so I guess we should close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform/Windows/Non-WSL2 Microsoft Windows (non-WSL2)
Projects
None yet
Development

No branches or pull requests