Error while sharing local drive(volume) with docker for windows

Viewed 7371

I am getting below error when I try to share local drive(volume) with docker for windows

docker run --rm -v c:/Users:/data alpine ls /data
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: C: drive is not shared. Please shar
e it in Docker for Windows Settings.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.

I tried sharing the folder from the docker settings and provided my username and password but no luck and getting same error

5 Answers

I had a similar issue with the error message "docker: Error response from daemon: Drive sharing failed for an unknown reason."

I opened the docker settings > Shared Drives > checked on C drive > Click Apply and re-started docker to resolve the issue

windows docker settings

I was facing a similar issue when starting containers with docker-compose. I got an error:

A firewall is blocking file sharing between Windows and the containers.

Then I checked settings for Docker and under Shared Drives section I tried to check the checkbox for C: drive, but after hitting apply checkbox unchecked itself.

Then I copied the line docker run --rm -v c:/Users:/data alpine ls /data into Powershell, ran it and got the error:

Drive sharing failed for an unknown reason.

But after this error, I decided to just try restarting Docker. After the restart, I tried to check the checkbox in the Shared Drives section once again and now it stayed checked and everything is working as it should.

I was using Docker Stable version.

I was dealing with similar issue during setup. I couldn't share my directories with Docker because I was using my Azure AD login credentials. You need to create a local admin user. If the local admin doesn't appears right away you would need to reinstall Docker under local admin user. I hope this helps someone struggling with similar issue.

Like Shweta Gupta was saying, if you are using an AzureAD user, you'll need to create a local account on your machine, and use that to give Docker permissions to the drive.

Related