Minikube mounted host folders are not working Minikube mounted host folders are not working docker docker

Minikube mounted host folders are not working


It's not so easy as minikube is working inside VM created in Virtualbox that's why using hostPath you see that VM's file system instead of your PC.

I would really recommend to use minikube mount command - you can find description there

From docs:

minikube mount /path/to/dir/to/mount:/vm-mount-path is the recommended way to mount directories into minikube so that they can be used in your local Kubernetes cluster.

So after that you can share your host's files inside minikube Kubernetes.

Edit:

Here is log step-by-step how to test it:

  ~ minikube start* minikube v1.3.0 on Ubuntu 19.04* Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.* Starting existing virtualbox VM for "minikube" ...* Waiting for the host to be provisioned ...* Preparing Kubernetes v1.15.2 on Docker 18.09.6 ...* Relaunching Kubernetes using kubeadm ... * Waiting for: apiserver proxy etcd scheduler controller dns* Done! kubectl is now configured to use "minikube"  ~ mkdir -p /tmp/test-dir  ~ echo "test-string" > /tmp/test-dir/test-file  ~ minikube mount /tmp/test-dir:/test-dir* Mounting host path /tmp/test-dir into VM as /test-dir ...  - Mount type:   <no value>  - User ID:      docker  - Group ID:     docker  - Version:      9p2000.L  - Message Size: 262144  - Permissions:  755 (-rwxr-xr-x)  - Options:      map[]* Userspace file server: ufs starting* Successfully mounted /tmp/test-dir to /test-dir* NOTE: This process must stay alive for the mount to be accessible ...

Now open another console:

  ~ minikube ssh                         _             _                        _         _ ( )           ( )             ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  /' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)$ cat /test-dir/test-file test-string

Edit 2:

example job.yml

apiVersion: batch/v1kind: Jobmetadata:  name: testspec:  template:    spec:      containers:      - name: test        image: ubuntu        command: ["cat", "/testing/test-file"]        volumeMounts:        - name: test-volume          mountPath: /testing      volumes:      - name: test-volume        hostPath:          path: /test-dir      restartPolicy: Never  backoffLimit: 4