docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.86k stars 290 forks source link

Empty volumes when specifying a remote host #298

Closed MatthewMiele closed 7 years ago

MatthewMiele commented 7 years ago

Im not to sure where this issue lies or if its even an issue (might be something thats not supported?) but as I could not find any documentation on this I am opening this ticket.

I have Docker installed on Windows 10 (using HyperV) and inside Bash for Windows (Ubuntu) I have just the docker client.

The problem is that when I run my container using -H tcp://0.0.0.0:2375 the volumes that I specify are not mounted properly. It only seems to make the folders that appear in that directory, but when looking inside the mounts, in the container, they are empty.

When running the exact same command directly from Windows (not in Bash for Windows), the mounts work.

Im thinking maybe volumes are generally not supported when specifying a host? even though technically its the same machine in this case.

I have tried with several combinations.

This is the current version which works when using docker-compose in Windows, but not from Linux / Bash for Windows.

     -v ./app:/app

This is trying using the full path that the Linux system can access the files on. This result in an empty /app directory

     -v /mnt/d/Projects/Test/Backend/app:/app

This also results in an empty /app directory (The wouldn't match the first case, but its just as a test)

    -v .:/app

My Docker for Windows has my D:\ drive set as shared.

I hope that makes sense :)

Information

(Originally thought it was a docker-compose issue https://github.com/docker/compose/issues/4215, but the same result happens when using docker on its own)

friism commented 7 years ago

When running the Docker CLI from inside Bash for Windows, you likely won't be able to volume-mount folders that reside in the Bash for Windows filesystem. That's because that filesystem is not shared with the Linux VM running the Docker daemon - only the standard D:\ Windows filesystem is available to be volume-mounted into containers.

MatthewMiele commented 7 years ago

I understand that if trying to use the full path it wouldn't work. Such as /mnt/d/Projects/ .... But should using a relative path such . work?

Or does Docker for Windows do some kind of extra translation to resolve it to the correct path to match the shared path in the HyperV VM....and as the Docker client in bash is trying to talk straight to the daemon , this translation process isn't happening?

On 8 Dec 2016 1:53 am, "Michael Friis" notifications@github.com wrote:

When running the Docker CLI from inside Bash for Windows, you likely won't be able to volume-mount folders that reside in the Bash for Windows filesystem. That's because that filesystem is not shared with the Linux VM running the Docker daemon - only the standard D:\ Windows filesystem is available to be volume-mounted into containers.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/298#issuecomment-265630708, or mute the thread https://github.com/notifications/unsubscribe-auth/AHzYUOdNaoBPuQhS5WjFU578eIy1-QZ1ks5rF2MFgaJpZM4LHVPb .

friism commented 7 years ago

@MatthewMiele no, relative path wouldn't work either. When you shared the "D:\" drive with Docker, that made the files and folders on the D: drive available to be volume mounted into containers. But since the Bash on Windows filesystem is not represented on the D-drive, you can't mount relative paths from there. It might work if you mounted something like D:\foo\bar.

MatthewMiele commented 7 years ago

That's does not work as Linux complains that that is not a valid / existing path :(.

So it looks like it can't be done.

But are volumes even supported when using remote hosts in general?

On 8 Dec 2016 3:22 pm, "Michael Friis" notifications@github.com wrote:

@MatthewMiele https://github.com/MatthewMiele no, relative path wouldn't work either. When you shared the "D:" drive with Docker, that made the files and folders on the D: drive available to be volume mounted into containers. But since the Bash on Windows filesystem is not represented on the D-drive, you can't mount relative paths from there. It might work if you mounted something like D:\foo\bar.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/298#issuecomment-265766429, or mute the thread https://github.com/notifications/unsubscribe-auth/AHzYUHDXZJEOnFFvGS2VMUnmRC7PzuF9ks5rGCDIgaJpZM4LHVPb .

PetaPetaPeta commented 7 years ago

I have the same setup. The way I got it to work is mounting the volume with the absolute Windows path. So instead of the /mnt/d/...-path you should use D:/....

MatthewMiele commented 7 years ago

Ah! Yes that works! Thanks Peter. I didn't think to try that, I assumed that would be one case that definitely wouldn't work! Ha

Also I had been using the relative paths because it allowed me to use the same compose file if I'm on my windows does machine or Linux machine. Using the absolute Windows path means I wouldn't be able to do that.

On 9 Dec 2016 10:02 am, "Peter Poulsen" notifications@github.com wrote:

I have the same setup. The way I got it to work is mounting the volume with the absolute Windows path. So instead of the /mnt/d/...-path you should use D:/....

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/298#issuecomment-265977004, or mute the thread https://github.com/notifications/unsubscribe-auth/AHzYUG0s_MuOJii_y4ONdalJdRj1o54wks5rGScagaJpZM4LHVPb .

PetaPetaPeta commented 7 years ago

@MatthewMiele I think it's probably faulty behavior that the relative path is converted to an absolute path on the client you are running on irrespective of the value of DOCKER_HOST. The conversion should probably be done by the docker server instead to ensure that it is correct. Maybe we should open an issue to ask for this feature? I have same issue with the relative paths being way more convenient for running the compose file on multiple platforms.

friism commented 7 years ago

But are volumes even supported when using remote hosts in general?

The general answer is "no" - host volume mounting only works when on the same host as the daemon or if there's special handling (as is the case with Docker for Windows).

docker-robott commented 4 years ago

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