I tried to mount folder of my project from /var/www to the same folder in container but folder in container is empty. Problem is maybe with host folder permissions because if i try that with some other folder it works.
docker run -it -v ~/Downloads:/var/www debian:jessie /bin/bash
This doesn't work:
docker run -it -v /var/www:/var/www debian:jessie /bin/bashAnswer1:
You cannot mount any folders outside your homedir ~/, this is the VM restriction on Mac and Windows. When the Virtualbox is created it mounts the folders within your Users directory, which makes it the only folder available to the containers <a href="https://github.com/docker/kitematic/issues/1192" rel="nofollow">https://github.com/docker/kitematic/issues/1192</a>
By default, Machine will only share your home directory. If you want to add more, you need to add them using the VirtualBox UI. <a href="https://github.com/docker/machine/issues/1814" rel="nofollow">https://github.com/docker/machine/issues/1814</a>Answer2:
In addition to vitr's great answer above, if you are using <a href="https://github.com/codekitchen/dinghy" rel="nofollow">Dinghy</a> with your docker containers, then on your local machine check the setting of <strong>DINGHY_HOST_MOUNT_DIR</strong> and <strong>DINGHY_GUEST_MOUNT_DIR</strong> <em>that the folder you are trying to mount is below what is specified</em> in the above environment variables. If those env. vars are not specified then your home directory is assumed.
$ env | grep DINGHY_HOST_MOUNT_DIR DINGHY_HOST_MOUNT_DIR=/Users/ro/my_docker_workspace $ env | grep DINGHY_GUEST_MOUNT_DIR DINGHY_GUEST_MOUNT_DIR=/Users/ro/my_docker_workspace
So in the case above, I can only mount local folders in my_docker_workspace and below.