Docker osx挂载的文件夹是空的

时间:2016-06-16 09:58:55

标签: bash macos docker

我尝试将项目的文件夹从/ var / www挂载到容器中的同一文件夹,但容器中的文件夹为空。问题可能在于主机文件夹权限,因为如果我尝试使用其他文件夹,则可以使用。

这有效:

docker run -it -v ~/Downloads:/var/www debian:jessie /bin/bash

这不起作用:

docker run -it -v /var/www:/var/www debian:jessie /bin/bash

2 个答案:

答案 0 :(得分:3)

您无法在homedir之外安装任何文件夹〜/,这是Mac和Windows上的VM限制。创建Virtualbox后,它会在Users目录中安装文件夹,这使其成为容器https://github.com/docker/kitematic/issues/1192

可用的唯一文件夹。

默认情况下,Machine只会共享您的主目录。如果要添加更多内容,则需要使用VirtualBox UI添加它们。 https://github.com/docker/machine/issues/1814

答案 1 :(得分:0)

In addition to vitr's great answer above, if you are using Dinghy with your docker containers, then on your local machine check the setting of DINGHY_HOST_MOUNT_DIR and DINGHY_GUEST_MOUNT_DIR that the folder you are trying to mount is below what is specified 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.

相关问题