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

Empty folder in container when mounting a host directory #22981

Closed
aharpervc opened this Issue May 25, 2016 · 55 comments

Comments

Projects
None yet
@aharpervc

aharpervc commented May 25, 2016

  • pretty sure there's no exact duplicate open issue, but #21535 may be related, not sure

Output of docker version:

Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Wed Apr 27 00:34:20 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Wed Apr 27 00:34:20 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 1
Server Version: 1.11.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 7
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge null host
Kernel Version: 4.4.8-boot2docker
Operating System: Boot2Docker 1.11.1 (TCL 7.0); HEAD : 7954f54 - Wed Apr 27 16:36:45 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995 MiB
Name: test-machine
ID: KAM5:NASP:4VCU:TM2C:GFQR:QOZ3:S3CT:N4CM:FRNJ:HHGU:UNFO:2D4L
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug mode (client): false
Debug mode (server): true
 File Descriptors: 12
 Goroutines: 30
 System Time: 2016-05-25T15:29:28.874791658Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
 provider=hyperv

Additional environment details (AWS, VirtualBox, physical, etc.):

  • docker environment set up with docker-machine using hyperv on windows 10

Steps to reproduce the issue:

Here's my full command history

  1. create new folder, and create a new text file in the folder
  2. run docker-machine create test-machine
  3. run the commands to set up the environment
  4. run docker run -i -t -v /c/users/aharper/workspace_test_docker_volume:/whatever ubuntu /bin/bash

Describe the results you received:

I expected to see the host folder contents in /whatever in the container

Describe the results you expected:

/whatever exists in the container but is empty

Additional information you deem important (e.g. issue happens only occasionally):

Seems to always happen. No errors that I noticed. The mounting process seems to almost work since the folder itself shows up.

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 25, 2016

I've seen some reports where the Windows/VirtualBox shared mount wasn't started properly in the virtual machine. Could you try restarting the VirtualBox VM?

Also, if you didn't do so yet, I recommend registering for the Docker for Windows beta, which solves a lot of these issues (#21535 (comment)). You can register at https://beta.docker.com; feel free to ping me here after you did so, and if you give me your Docker Hub ID (username), I can try getting you into the beta faster

@aharpervc

This comment has been minimized.

aharpervc commented May 25, 2016

I created the docker machine with Hyper-V, not VirtualBox, however restarting the vm did not seem to change the situation. Docker Hub username is aharper.

@friism

This comment has been minimized.

Contributor

friism commented May 25, 2016

@aharpervc @thaJeztah I don't think the hyper-v driver does host (win) to guest (boot2docker) filesharing, so volume-mounting from the host windows 10 filesystem is not expected to work.

@thaJeztah seperately, it might be good to document what machine drivers are expected to have working host volume mounting (only the virtualbox one, as far as I know)

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 25, 2016

Ah! Yes, the Hyper-V machines don't have this as an option, only VirtualBox (and Docker for Windows)

@friism probably, yes, but that should go in the https://github.com/docker/machine issue tracker. Could you open an issue there?

@aharpervc looks like that answers your question, so I'll close this issue, but feel free to continue the discussion here 👍

@friism

This comment has been minimized.

Contributor

friism commented May 25, 2016

@aharpervc

This comment has been minimized.

aharpervc commented May 25, 2016

Hopefully that doc change will make its way into the website, which is silent on this critical deficiency and implies that it will work normally.

https://docs.docker.com/engine/userguide/containers/dockervolumes/#mount-a-host-directory-as-a-data-volume

On Windows, mount directories using:

docker run -v /c/Users/:/ ...`

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 25, 2016

@aharpervc I agree we should have something mentioning it. It's sometimes difficult finding the right balance, because this basically is an issue in docker machine, not "docker (engine)", and there's now four possible setups on Windows (native Windows docker, Docker toolbox (VirtualBox), Docker Machine (Hyper-V), and "Docker for Windows (beta)"

@carrete

This comment has been minimized.

carrete commented May 25, 2016

This happens for us when using Docker for Windows (beta)

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 25, 2016

@carrete I'm not on Windows myself, but could you check this section? https://beta.docker.com/docs/windows/troubleshoot/#host-filesystem-sharing

@rebeccamadsen

This comment has been minimized.

rebeccamadsen commented May 26, 2016

I enabled file and printer sharing on Windows 10, following that section. When I try to enable sharing a local drive using Docker Beta, the username/password screen just keeps popping up again whenever I click submit.

@carrete

This comment has been minimized.

carrete commented May 26, 2016

Thanks @thaJeztah . We tried that, but the problem is as @rebeccamadsen describes: #22981 (comment). She opened an issue about this: #23005

@aharpervc

This comment has been minimized.

aharpervc commented May 26, 2016

I have the "Docker for Windows" beta, and confirmed that it's still an issue. Additionally, under the "Shared Drives" panel of the Settings screen, the command docker run -v c:/Users:/data alpine ls /data is suggested, but doesn't work (returns empty listing.... no files in mounted folder)

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 26, 2016

Apparently there are still some issues with sharing host-mounts on Windows with the Docker for Windows beta. The best source of information currently is the troubleshooting documentation linked above, and this forum topic on the docker for windows beta forum; https://forums.docker.com/t/volume-mounts-in-windows-does-not-work/10693/53

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 26, 2016

I realize that's not a full answer, but I know the Docker for Windows team is working hard to improve the reliability of this feature on Windows. 😊

@habbes

This comment has been minimized.

habbes commented May 30, 2016

@thaJeztah I have the same problem on my machine. The directory is created in the container but is empty, it is also properly listed in Mounts when I run docker inspect. However it worked fine last week when I tried it out a couple of times, don't know why it's not working today. I have the Docker Toolbox and VirtualBox setup.

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 30, 2016

@habbes you could try a reboot of the VM; I heard that helped some people, where VirtualBox file-sharing wasn't started for some reason

@habbes

This comment has been minimized.

habbes commented May 30, 2016

@thaJeztah I tried that, tried restarting the docker machine, virtualbox and even the whole computer. Nothing. Let me keep searching for a solution

@habbes

This comment has been minimized.

habbes commented May 31, 2016

@thaJeztah It's working now. Not really sure where I went wrong. I notice it works if I map the volume to a directory that doesn't exist in the docker container. If I map it to an existing directory, it comes empty. I don't know whether that's the expected behavior. Thanks anyway.

@KevinM2k

This comment has been minimized.

KevinM2k commented Jun 9, 2016

I have same issue on windows for beta, it creates the folder in the container but doesn't have the contents of the drive from the windows dir

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Jun 9, 2016

@KevinM2k can you report that issue in the Docker for Windows beta forum? I think there's already a topic for it https://forums.docker.com/c/docker-for-windows

@jimudall

This comment has been minimized.

jimudall commented Jun 15, 2016

Beyond strange. I've been working on this all day. I'm using Windows 7 and Docker Toolbox. Here's how it started

  1. Mounting of a Virtualbox shared container was working
  2. I then wanted to mount a different folder in my container (albeit still in the shared folder of my host machine)
  3. When I did so, the mount in the container SORT of worked. In particular, it merged the old folder with the new one! Tres bizzare!
  4. Been jumping through ALL the hoops google has been suggesting...including destroying the VM. Nothing works...EXCEPT
    5 Now it doesn't matter what folder I try to mount. If it's a shared folder from the host, it shows up as empty in the container
  5. Mounting a non-shared folder seems fine.
  6. Totally stumped. I can't even get back to the merged behaviour
@MoOx

This comment has been minimized.

MoOx commented Jun 29, 2016

This might help https://docs.docker.com/docker-for-windows/troubleshoot/#/host-filesystem-sharing

Unfortunately, this setup does not support passwords which contain Unicode characters, so your password must be 8-bit ASCII only.

@aharpervc

This comment has been minimized.

aharpervc commented Jul 7, 2016

The guidance in this comment, to change the DockerNAT virtual adapter from public to private network type, fixed the issue for me.

@marc1404

This comment has been minimized.

marc1404 commented Sep 14, 2016

@wmario I tried your steps but without upgrading Windows 10. Shared folders are still empty for me inside the guest container.
Windows 10 Pro
Version 1511
Docker for Windows Version 1.12.0-stable (build: 5968)

@wmario

This comment has been minimized.

wmario commented Sep 14, 2016

@wmario

This comment has been minimized.

wmario commented Sep 15, 2016

I upgraded docker to latest version (again)...

and again my shared drives was broken !!!

So I went to hyper-v console again to check this
[image: Images intégrées 1]
the last check boxe here was not checked ! again....

So I checked all and restart docker from the docker applet... And it is
working again.

Best regards,
Willy.

2016-09-14 17:48 GMT+02:00 Willy mario wmario.wm@gmail.com:

Hi
Sorry for this I am running latest build of docker 1.21.1-beta25 build
6823... And it is still running.

Si maybe it is the latest w10 hyper-v which revolves the issue... 🙁

@dgleba dgleba referenced this issue Sep 16, 2016

Closed

403 forbidden #3

@masaeedu

This comment has been minimized.

Contributor

masaeedu commented Sep 19, 2016

@friism Is there a particular reason this is done by asking you for your password instead of using UAC? Relying on Windows' built in elevation mechanism seems like it would be more secure and would bypass the unicode issues we're seeing. If the user doesn't like UAC prompts (e.g. if they're on a dev box) they'll already have the notification level set to low, or will run docker in an elevated process.

@SeriousM

This comment has been minimized.

SeriousM commented Sep 19, 2016

@thaJeztah could you please add me to the beta-list? name is SeriousM . I'm running Win10 and my shared folders are empty. Thank you!

@friism

This comment has been minimized.

Contributor

friism commented Sep 19, 2016

@SeriousM there's no beta list, you can install the beta-channel version from here: https://docs.docker.com/docker-for-windows/

@SeriousM

This comment has been minimized.

SeriousM commented Sep 19, 2016

Thank you, and sorry for the distribution!

Am 19.09.2016 21:57 schrieb "Michael Friis" notifications@github.com:

@SeriousM https://github.com/SeriousM there's no beta list, you can
install the beta-channel version from here: https://docs.docker.com/
docker-for-windows/


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#22981 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAcMvYcu0hbCoAIIrHIARdy6npZPyWTjks5qrukqgaJpZM4ImqtR
.

@yuval-mntr

This comment has been minimized.

yuval-mntr commented Oct 19, 2016

https://forums.docker.com/t/volume-mounts-in-windows-does-not-work/10693/71

@soheilalizadeh

This comment has been minimized.

soheilalizadeh commented Jan 4, 2017

I installed Docker with Docker toolbox and this is how I solved it:

  1. Open the Oracle VM
  2. Go to the settings of the VM for docker (mine was default)
  3. Shared Folders
  4. Add new shared folder (e.g. I wanted to mount E:\X -> Folder path : E\X and Folder name: e/X)
  5. Shutdown the VM
  6. Run Docker terminal
@deep-c

This comment has been minimized.

deep-c commented Feb 21, 2017

Hi I am experiencing the same problem and have exhausted everything i can think of. I am attempting to mount a volume from C:/Users into a container running on a docker-machine using the hyperv driver on docker for windows (win 10 pro). I am a using the lastest docker (1.13.1) and the same on the hyper vm machine. I have tried switching to using a local account, shared the drive in the docker settings menu and ive pretty much tried everything i could find on google.

Running the test volume run command in the settings menu works for me. At this point in time I presume hyperv does not support mounting volumes from the host however i cant find anywhere that explicitly says that volumes mounting will not work in hyperv.

This is my docker-compose config:

networks: {}
services:
  app:
    build:
      context: C:\users\deep\projects\chat\app
    command: sleep 3600
    image: app
    links:
    - rethinkdb
    - redis
    ports:
    - 4005:4005
    - 4007:4007
    volumes:
    - /c/users/deep/projects/chat/app:/usr/src/app:rw
  redis:
    image: redis
  rethinkdb:
    image: rethinkdb:2.3.5
version: '2.0'
volumes: {}

In my Dockerfile i can see copy files into the container to usr/src/app. When i up the services with the volume specified in the compose file the directory is emptied, however i omit this volume mount i can see my files that i copied into the container from the dockerfile.

Running verbose when starting my services i can see a volumes path specified as such 'Binds': [u'/c/users/deep/projects/chat/app:/usr/src/app:rw']. However, when i inspect the container using docker-compose inspect app i see volumes set to null "Volumes": null .

I presume at this point that mounting volumes into a container running inside a hyperv VM is not supported? Can someone confirm so that I can RIP :)

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Feb 21, 2017

@deep-c Docker for Windows supports bind-mounting host directories (see https://docs.docker.com/docker-for-windows/#shared-drives), however, if you use docker-machine to create a machine with hyperv, sharing won't work. I'd recommend to install Docker for Windows instead.

@deep-c

This comment has been minimized.

deep-c commented Feb 21, 2017

@thaJeztah Thanks for the confirmation! I presume you mean i should install Docker toolbox (and use virtualbox) when you said I'd recommend to install Docker for Windows instead?

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Feb 21, 2017

@deep-c No, docker toolbox / VirtualBox should not be needed. If you use Docker for Windows https://docs.docker.com/docker-for-windows/install/, you should be able to use shared drives. Docker for Windows also uses hyper-v, but has additional features in place to allow you to do that. Those features are not there if you create a hyper-v machine with docker-machine.

@alexgorbatchev

This comment has been minimized.

alexgorbatchev commented Sep 23, 2017

if you are trying to mount a folder from windows bash and getting empty results, you have to remove /mnt prefix...

so, instead of --volume /mnt/c/Users:/foo it should be --volume /c/User:/foo... Double slash also works --volume //c/User:/foo

@omarramadan

This comment has been minimized.

omarramadan commented Nov 21, 2017

Had the same issue This is on windows 10.. Solved it by doing the following
Docker Setting -> Shared Drive -> Reset credentials.
This was after I had changed my windows password.

@snewell92

This comment has been minimized.

snewell92 commented Dec 7, 2017

@omarramadan I didn't even know I needed to grant those permissions by supplying credentials to the windows partitions 😮 . The tuts didn't really mention that...

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Dec 7, 2017

@snewell92 could you open an issue for that in the documentation issue tracker? There's a "request documentation changes" link on the page you referred to to open an issue

@krufab

This comment has been minimized.

krufab commented Jan 10, 2018

It's an old post, but this might help:
On Windows, antivirus and similar softwares might prevent docker to access the local file system.
Even if drive sharing is enabled on docker.

@chnakamura

This comment has been minimized.

chnakamura commented Feb 27, 2018

This does not work in VMWare Fusion either, was very confused until I read this.

@tvolkov

This comment has been minimized.

tvolkov commented Apr 18, 2018

@omarramadan Thank you! Resetting credentials worked for me

@RogerioDosSantos

This comment has been minimized.

RogerioDosSantos commented Apr 25, 2018

Be aware that when changing your password, you will need to go to settings >> shared drivers >> reset credentials. Once you select the drivers you want to share again and enter the new password, everything will start working again.

@m0onspell

This comment has been minimized.

m0onspell commented Apr 28, 2018

I fixed this issue by moving a project to C:\ drive. Using Docker Toolbox on Windows 7.

@RaynaDA

This comment has been minimized.

RaynaDA commented May 17, 2018

I tried every flavour of -v, finally gave up and used --mount and all is well (using Windows 10 and Docker for Windows).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment