40

While trying to run this command :

docker-compose up

I get this error :

Error response from daemon: user declined directory sharing C:\Users\path_to_my_folder

I am working on windows 10

Michael Ribbons
  • 1,753
  • 1
  • 16
  • 26
Mathieu Ract
  • 411
  • 1
  • 3
  • 3
  • 1
    Possible duplicate https://stackoverflow.com/q/59942110/596285 – BMitch Jan 27 '22 at 11:30
  • Does this answer your question? [Error mounting a config file into the container](https://stackoverflow.com/questions/43755922/error-mounting-a-config-file-into-the-container) – Affes Salem Jan 31 '22 at 00:13
  • According to the [documentation](https://docs.docker.com/desktop/settings/windows/#file-sharing) this problem is only relevant for Docker running on Windows in Hyper-V mode. Tagging it with "docker-windows-hyperv" or similar might be helpful. – otterrisk Aug 14 '23 at 10:04

5 Answers5

77

You have to add C:\Users\path_to_my_folder to Docker Filesharing. Go to docker dashboard -> settings ->Resources -> FileSharing. Add required folder and hit Apply & Restart.

Stefan Vukovic
  • 990
  • 6
  • 12
12

Normally, Docker will display a desktop notification asking for your confirmation before sharing the folder.

Docker sharing confirmation notification

However, if notifications are disabled (for example, if you enabled Focus Assist), the confirmation box won't show and Docker will automatically decline the permission.

Benoit Blanchon
  • 13,364
  • 4
  • 73
  • 81
7

Open Docker and follow this -> settings ->Resources -> FileSharing. Add required folder and hit Apply & Restart

Kamran Huseyn
  • 71
  • 1
  • 1
1

If you have missed the notification or want to add any file or delete existing shared file path, go to Settings -> Resources -> Use the +/- button -> Click Apply and Restart

enter image description here

0

Answer from Kamran Huseyn worked for me perfectly on windows (this issue is not observed in my MacOS terminal).

Open Docker and follow this -> settings ->Resources -> FileSharing. Add required folder and hit Apply & Restart!

mcxcr
  • 9
  • 1