简体   繁体   中英

How do I mount a network volume inside my Docker Windows container

I need to share a network drive inside my Windows docker container under the A: drive. The network drive I need to shared is not empty, and I would need to access it with and right permissions. How can I achieve this? I've only found posts about people mapping their C: drive.

Should it be done during build or at runtime?

It tried the obvious

docker run -it --rm --name windows my/image --privileged -v \\\\ip\\mount\\my\\folder:A:\\my\\folder

but I get this error:

[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF6F8AFAE77: (caller: 00007FF6F8AAE4AB) Exception(2) tid(39c) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]

I'm using Docker Desktop 2.2.0.0 on Windows 10 Pro 1903

Edit: I should have set the image after the volumes it seems. With the following command, The error is different:

docker run -it --rm --name windows --privileged -v \\\\ip\\mount\\my\\folder:A:\\my\\folder my/image

docker: Error response from daemon: invalid volume specification: '\\\\ip\\mount\\my\\folder:A:my\\folder'

You need to create gMSAs for Docker container. Actually, th IT Team should do it for you (following this tutorial , for example). They will then provide you with a credentials file. You can then run your docker container with:

docker run -it --rm --name windows --security-opt "credentialspec=file://my_credentials.json" my/image

then, in the container, you can use net use to mount your volume under the letter you want. You can't do it in the container run command, however.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM