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

Mounting a Windows share to a container #6083

Closed
Hamsterman opened this issue Mar 19, 2020 · 9 comments
Closed

Mounting a Windows share to a container #6083

Hamsterman opened this issue Mar 19, 2020 · 9 comments

Comments

@Hamsterman
Copy link

Hamsterman commented Mar 19, 2020

I have been looking hundreds of post that try to explain how to map a share to a container - but still no luck.

My setup

  • Window Server 2019
  • Docker Desktop (docker version 19.03.2)
  • Docker containers set to "Linux Containers"
  • Docker Engine config have an extra line: "experimental": true
  • NFS server enabled
  • SMB 1.0/CIFS enabled
  • A share called DockerShare on the same machine (Everyone Full Control on share and Filesystem).

It seems that some people have this working:
docker volume create --driver local --opt type=nfs --opt o=addr=127.0.0.1,hard,nolock,rw --opt device=:/DockerShare bar
docker run -it -v bar:/server-dev alpine sh

But I get this error:
C:\Program Files\Docker\docker.exe: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/bar/_data': failed to mount local volume: mount :/DockerShare:/var/lib/docker/volumes/bar/_data, data: addr=127.0.0.1,hard,nolock: operation not supported.

When I switch to nfs4 I get a different error.
docker volume create --driver local --opt type=nfs4 --opt o=addr=127.0.0.1,hard,nolock,rw --opt device=:/DockerShare bar
docker run -it -v bar:/server-dev alpine sh

C:\Program Files\Docker\docker.exe: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/bar/_data': failed to mount local volume: mount :/DockerShare:/var/lib/docker/volumes/bar/_data, data: addr=127.0.0.1,hard,nolock: connection refused.

Why is this so hard ? - shouldn't it be possible to code something that just work without so many problems.

By the way I did this as well
docker run -it -v //127.0.0.1/DockerShare:/server-dev alpine sh
No errors but I could not see the files from the DockerShare in the server-dev folder.
I tried to create a folder in the server-dev folder from within my container to my surprise it was still there after exited the container, removed it, did a docker volume prune and executed
docker run -it -v //127.0.0.1/DockerShare:/server-dev alpine sh
again.
Also I did a search for the folder I created but it could not be found on the Window host.

On last thing - I tried the "standard" way which is activating sharing of the C drive in Docker Deskop.
Then I started the container like this:
docker run -it -v /c/SomeTest/:/server-dev alpine sh
That works just fine - I can see the content of C:\SomeTest and I can add files in it which shows instant in the server-dev folder.

The confusion is complete!

@mat007
Copy link
Member

mat007 commented Mar 20, 2020

This does not look like an issue with the Docker Desktop application itself but with the upstream docker windows container implementation so I'm closing this issue. Could you please open an issue on https://github.com/moby/moby instead as that is the more appropriate place?

@mat007 mat007 closed this as completed Mar 20, 2020
@mat007
Copy link
Member

mat007 commented Mar 20, 2020

Well hold on, sorry, file sharing is kind of tied to Docker Desktop as well actually.
You need to tell us what version of Docker Desktop you’re running and also if possible upload diagnostics (Troubleshot menu from the systray menu).

@mat007 mat007 reopened this Mar 20, 2020
@Hamsterman
Copy link
Author

I am running: DockerDesktop 2.2.0.4
Diagnostics ID: 8EE5C91D-2005-41AC-8260-F66F5D875017/20200320080802

@djs55
Copy link

djs55 commented Mar 20, 2020

@Hamsterman thanks for your report. If you have a moment could you describe your use-case a little? We focus our testing on the "standard" way for file sharing rather than NFS or CIFS.

I suspect the reason NFS isn't working is because in

docker volume create --driver local --opt type=nfs4 --opt o=addr=127.0.0.1

The 127.0.0.1 is unfortunately the localhost inside the helper Linux VM, not the Windows 127.0.0.1. Could you try replacing this with host.docker.internal (which resolves to an internal IP which can be used to contact the host)

I don't believe this syntax is supported: docker run -it -v //127.0.0.1/DockerShare. I think your initial attempt with docker volume create is the right approach, if you really want to use NFS/CIFS.

@Hamsterman
Copy link
Author

Hamsterman commented Mar 20, 2020

First of all I have no favorite protocol I would like to use at this point in time. I just wanna see just one work. The use case is simple to have a persistent storage on a share (I am testing with a Windows Share). I have tried with the nfs4 as you can see below.

If I use host.docker.internal
docker volume create --driver local --opt type=nfs4 --opt o=addr=host.docker.internal,hard,nolock,rw --opt device=:/DockerShare bar
docker run -it -v bar:/server-dev alpine sh

C:\Program Files\Docker\docker.exe: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/bar/_data': failed to mount local volume: mount :/DockerShare:/var/lib/docker/volumes/bar/_data, data: addr=host.docker.internal,hard,nolock: invalid argument.

And if I use the actual IP of the Windows host
docker volume create --driver local --opt type=nfs4 --opt o=addr=192.168.X.X,hard,nolock,rw --opt device=:/DockerShare bar
C:\Program Files\Docker\docker.exe: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/bar/_data': failed to mount local volume: mount :/DockerShare:/var/lib/docker/volumes/bar/_data, data: addr=192.168.5.33,hard,nolock: protocol not supported.

@Hamsterman
Copy link
Author

bump

@Hamsterman
Copy link
Author

bump again

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Sep 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants