Damo
Damo

Reputation: 6433

Mounting a local folder in docker results in an empty directory

First my setup:

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

Upvotes: 0

Views: 1399

Answers (1)

Andreas Lorenzen
Andreas Lorenzen

Reputation: 4230

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

enter image description here

And then test with:

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

Upvotes: 2

Related Questions