I can't mount a folder on Docker on Windows. I'm using the repository https://github.com/LaraDock/laradock. In docker-compose.yml
, line 23, there is a folders mapping:
application:
build: ./application
volumes:
- ../:/var/www/laravel
In the VirtualBox folder, D:\VM
is shared. When I start the container and list files there is just the laradock
folder, but I have a whole Laravel installation in that folder that should be, but isn't listed.
username@pc MINGW64 /d/VM/zemke2/laradock (master)
$ docker-compose up -d nginx mysql
Starting laradock_application_1
Starting laradock_data_1
Starting laradock_workspace_1
Starting laradock_php-fpm_1
Starting laradock_nginx_1
Starting laradock_mysql_1
username@pc MINGW64 /d/VM/zemke2/laradock (master)
$ docker exec -it laradock_workspace_1 bash
root@c9dbb37ace74:/var/www/laravel# ls
laradock
When I try to mount from inside the machine, I get permission denied:
root@c9dbb37ace74:/var/www/laravel# mount --bind /d/VM/zemke2/laradock /var/www/laravel
mount: permission denied
root@c9dbb37ace74:/var/www/laravel# sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) VM /var/www/laravel
mount: permission denied
root@c9dbb37ace74:/var/www/laravel#
When I try to bind from Docker it is silent, but the folder isn't mounted, and files aren't listed.
username@pc MINGW64 /d/VM/zemke2/laradock (master)
$ docker run --privileged=true -it -v '//d/VM/zemke2/laradock:/var/www/laravel' laradock_application bash
root@01dff4894074:/var/www/laravel# ls
logs
Here is debug information for a container that defines volume mapping:
username@pc MINGW64 /d/VM/zemke2/laradock (master)
$ docker inspect laradock_application
[
{
"Id": "sha256:edc4295d69f048a5ce31bdfb86fbe2132b4a3c070377028efabaed3f82235dfd",
"RepoTags": [
"laradock_application:latest"
],
"RepoDigests": [],
"Parent": "sha256:44f94094c21c3541793d77ae0635bce470a8ee3bc6af4e9d3e902530d373e62b",
"Comment": "",
"Created": "2016-05-22T22:30:28.379420591Z",
"Container": "a990cb7f02784411fce8969a6926ab39dcba1f59ad99f055b77ba8eb9b954c0a",
"ContainerConfig": {
"Hostname": "f416997e8b71",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"true\"]"
],
"Image": "sha256:44f94094c21c3541793d77ae0635bce470a8ee3bc6af4e9d3e902530d373e62b",
"Volumes": null,
"WorkingDir": "/var/www/laravel",
"Entrypoint": null,
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "1.11.1",
"Author": "Mahmoud Zalt \u003cmahmoud@zalt.me\u003e",
"Config": {
"Hostname": "f416997e8b71",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"true"
],
"Image": "sha256:44f94094c21c3541793d77ae0635bce470a8ee3bc6af4e9d3e902530d373e62b",
"Volumes": null,
"WorkingDir": "/var/www/laravel",
"Entrypoint": null,
"OnBuild": [],
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 125093399,
"VirtualSize": 125093399,
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:6eb35183d3b8bb6aee54874076fb1ad77b5259c93b330986b0cbcaa44cbbbc00",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:60e06fa5d2311255186d98d3cd5709c4f5f08a24a356f468beebb19749acbd10"
]
}
}
]
When using Docker Toolbox, it is a two-step process to mount a folder to a container. On Windows/OS X, Docker runs inside a VirtualBox VM. First, you need to mount your Windows/OS X folder to VirtualBox. Second, you can then mount the VirtualBox folder to Docker using volumes. Docker does not have access to your Windows/OS X folders except the User folder (which is because the VirtualBox VM mounts that folder to the VM by default)
If you mounted your
D:/VM
folder to/d/vm
on the virtual machine, then you can change the volumes section of your Docker Compose file to- /d/vm/zemke2/laradock:/var/www/laravel
Also see this answer: Docker toolbox: Is there a way to mount other folders than from "C:\Users" Windows?
For those who are using Docker for Windows (on Hyper-V):
If you experience this issue when using Laradock or any other container, please make sure you select your drives under Shared Drives and add the credentials of a user with access to those same drives. Some people also have experienced this same issue when their passwords contain spaces or special characters. It's also worth noting that you should add your username like this: hostip\username
Another possible solution would be to temporarily disable your firewall and restarting Docker. I've seen this as being a more popular cause of Docker not being able to view project folders/filers. You'd need allow communication to/from the docker IP address, or better yet, change the policy of the virtual network adapter to one where sharing files/printers is allowed (i.e Private Network - this mainly depends of your own settings).
For even more solutions you might want to visit the Docker forums. This thread in particular contains heaps of other possible solutions, as this is a very common issue in the Windows environment.