0

My Docker container running in a minikube pod has configured a directory mounted from the host's non-empty /home/my_username/useful/dir. kubectl shows what I expect:

$ kubectl get --namespace=my_namespace pods/my-pod -o json | jq '.spec.volumes[3]'
{
  "hostPath": {
    "path": "/hosthome/my_username/useful/dir",
    "type": "Directory"
  },
  "name": "useful_dir"
}
$ kubectl get --namespace=my_namespace pods/my-pod -o json | jq '.spec.containers[].volumeMounts[3]'
{
  "mountPath": "/dir/in/container",
  "name": "useful_dir",
  "readOnly": true
}

But in the pod, the mountpoint is empty:

$ kubectl exec --stdin --tty --namespace my_namespace my-pod -- ls /dir/in/container
total 0

I looked at the pod's mountpoint with kubectl exec --stdin --tty --namespace my_namespace my-pod -- findmnt /dir/in/container, and see overlay[/hosthome/my_username/useful/dir]. From this, I conclude that Docker has mounted the directory from the host as expected.

I check the mountpoint directly from a pod's container (as root to make sure there is no permission restriction in the way):

$ docker exec -it -u root minikube /bin/bash
root@minikube:/# docker exec -it -u root <container_id> ls /dir/in/container
root@minikube:/#

It does not have any content which is present in the host.

What should I look for to investigate?

Konstantin Shemyak
  • 2,369
  • 5
  • 21
  • 41
  • What OS and Minikube driver are you using? – coderanger Jun 13 '21 at 20:25
  • OS: Linux, driver: Docker. – Konstantin Shemyak Jun 13 '21 at 20:43
  • 1
    Any chance you're running either docker or minikube inside a snap or some other non-global filesystem view? – coderanger Jun 13 '21 at 20:49
  • @coderanger you provided the clue! Minikube with Docker driver creates own pods inside own Docker container on the host. Thus for the containers running in the pod, their "host" is, in fact, the minikube's container! Naturally, the latter does not have `/home/my_username/useful/dir`. Solution: run `minikube --mount --mount-string='/home/my_username:/hosthome/my_username'`. If you wish, feel free to write this as an answer and I'll happily accept it! – Konstantin Shemyak Jun 14 '21 at 14:49

1 Answers1

1

Issue solved in comments, the driver was running dockerd inside a container itself so it didn't have a global filesystem view. Solved via minikube mount.

coderanger
  • 52,400
  • 4
  • 52
  • 75