Error response from daemon: error while creating mount source path permission denied

11/27/2019

This is my postgress config for K8s

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: postgres
  template:
    metadata:
      labels:
        component: postgres
    spec:
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: database-persistent-volume-claim
      containers:
      - name: postgres
        image: postgres
        ports:
        - containerPort: 5432
        volumeMounts:
          - mountPath: /var/lib/postgresql/data
            name: postgres-storage

Following is the event logs

Events:
  Type     Reason     Age                From                     Message
  ----     ------     ----               ----                     -------
  Normal   Scheduled  35s                default-scheduler        Successfully assigned default/postgres-deployment-d57b94d8-qnk8j to docker-desktop
  Normal   Pulling    11s (x3 over 34s)  kubelet, docker-desktop  Pulling image "postgres"
  Normal   Pulled     6s (x3 over 30s)   kubelet, docker-desktop  Successfully pulled image "postgres"
  Normal   Created    6s (x3 over 29s)   kubelet, docker-desktop  Created container postgres
  Warning  Failed     6s (x3 over 29s)   kubelet, docker-desktop  Error: failed to start container "postgres": Error response from daemon: error while creating mount source path '/host_mnt/c/Users/DupinderDhiman/.docker/Volumes/database-persistent-volume-claim/pvc-c8155b21-10d9-11ea-b05a-00155d380104': mkdir /host_mnt/c/Users/DupinderDhiman/.docker: permission denied

Yeah, I know you will say, share the drives. I did docker run --rm -v c:/Users:/data alpine ls /data

All Users
CatalystOne
Default
Default User
DupinderDhiman
Public
desktop.ini

this command runs very well

So the problem is not related to drive sharing

okay next problem may be related to c:/specificFolder permissions. I did I checked all the checkboxes in sharing permission

Now I am stuck

-- Dupinder Singh
docker-volume
kubectl
kubernetes
kubernetes-pvc

1 Answer

11/27/2019

So after spending some time, I remember I created one user to share drives for Docker with name dockerUser

So the Permission I gave are just for Administrative user My own User DupinderDhiman but not for dockerUser

So Goto C:/user/DupinderDhiman/.docker right click goto properties goto security tab Click on Edit button "To change permission, click Edit" and then click the Add button enter image description here

now click Advance > then on new dialogue find Find button in the bottom you will find one list, find DockerUser > Select it to press okay

enter image description here

enter image description here

Okay Okay Okay > apply changes

Close all the open dialogs with okay Apply changes and run the command. See you will not have this error now.

-- Dupinder Singh
Source: StackOverflow