10

Edit: I'm on windows.

I am experimenting with docker-compose. I know that I should use a Dockerfile to copy a file into the container, but I want to solve it by mounting the file because that is easier at the moment for my experiments. I also want to take this as a learning experience on what the issue is here.

My docker-compose.yml looks like this:

version: "3"
services:
  webserver:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./webapp.conf:/etc/nginx/conf.d/default.conf
  webapp:
    image: wordpress:php7.1-fpm

when running docker-compose up I see the following error message:

PS C:\Users\daniel\Documents\Docker> docker-compose up
Removing docker_webserver_1
Recreating ed1b21e6939c_docker_webserver_1
docker_webapp_1 is up-to-date

ERROR: for webserver  Cannot start service webserver: error while creating mount source path '/C/Users/daniel/Documents/Docker/webapp.conf': mkdir /C/Users/daniel/Documents: permission denied
ERROR: Encountered errors while bringing up the project.

What am I doing wrong.

h3xStream
  • 6,293
  • 2
  • 47
  • 57
Daniel
  • 3,092
  • 3
  • 32
  • 49

2 Answers2

11

(I added the same problem few minutes ago.)

Make sure your docker is allowed to mount the directory C:\Users\[redacted]\Documents\Docker

Configuration

In the Windows client, you can configure the docker to allow read/write on specific drives. This should fix your permissions problem.

enter image description here

Already configured ?

In my case, it was already selected. I unchecked and checked the drive again. Apply the "change". It prompted me for my Windows password (which had change) and than the mount worked again.

h3xStream
  • 6,293
  • 2
  • 47
  • 57
  • 4
    You can also get the permission denied error when the folder you are trying to mount on windows doesnt have the right permission settings. In my case, I had to edit the permissions of the source folder so that the Users group in my machine could access it. – Ernesto Jun 11 '19 at 17:56
1

To add a users group to a directory in Windows follow these steps:

  1. Right-click the directory
  2. Click properties
  3. click the security tab
  4. click the "Edit" button.
  5. click the add button
  6. Type "users" in the text box
  7. click "Check Names" (should auto fill/update for you)
  8. click okay
  9. Highlight your newly added group.
  10. Under "Permissions for [User/Groupname]" select Full control
  11. click apply
  12. Click "OK"
  13. Click "OK"

See also this Docker issue: https://github.com/docker/for-win/issues/3385

Erik_A
  • 138
  • 8