Mounting a local folder in docker results in an empty directory

允我心安 提交于 2020-01-06 06:41:22

问题


First my setup:

  • windows 10 (1709 16299.967)
  • wsl (ubuntu 18.04)
  • docker for windows 2.0.0.2 (30215) Engine 18.09.1

I'm trying to mount a local development folder as a volume within a docker container but the mounted directory is always empty. I have enabled the shared drive setting for c:/ through the docker for windows settings dialog.

I have tried mounting the local directory through WSL and powershell with no luck in either case. The commands I have tried are :

docker run -it -v /c/code/bitbucket/my-api:/var/my-api -w "/var/my-api" centos:7
docker run -it -v c:/code/bitbucket/my-api:/var/my-api -w "/var/my-api" centos:7
docker run -it -v c:\code\bitbucket\my-api:/var/my-api -w "/var/my-api" centos:7

In both WSL and powershell but all result in an empty /var/my-api folder

By the way if I put a folder that does not exist I get the following error:

➜  docker run -it -v /c/code/bitbucket/my-apizzz:/var/my-apizzz -w "/var/my-apizzz" centos:7
docker: Error response from daemon: Mount denied:
The source path "C:/code/bitbucket/my-apizzz"
doesn't exist and is not known to Docker.
See 'docker run --help'.

So I think I am using the correct syntax it's just that docker can't seem to access the file share


回答1:


I have seen this issue before. Try resetting your credentials here:

And then test with:

docker run --rm -v c:/code/bitbucket/my-api:/data alpine ls /data


来源:https://stackoverflow.com/questions/55071764/mounting-a-local-folder-in-docker-results-in-an-empty-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!