Mounting a local folder in docker results in an em

2019-08-18 17:12发布

问题:

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