When you are starting minikube with default docker driver, you are creating Docker VM inside your machine.
Background
When you are using your VM your terminal looks like:
user@nameofyourhost:~$
But if you will ssh to your Minikube VM terminal looks like below:
docker@minikube:~$
In HostPath you have information:
A hostPath volume mounts a file or directory from the host node's filesystem into your Pod.
In minikube when you are using hostPath, node is considered not your machine but the Minikube VM which was created during minikube start
Tests
As I dont have exactly your files, Ive used nginx. Please remember that you should have proper permissions to directories you want to mount. I've used tmp as in nginx this directory have full access for everyone.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
containers:
- name: test
image: nginx
ports:
- containerPort: 8080
volumeMounts:
- name: testing
mountPath: "/tmp/docker.jar" #this is path to the file
volumes:
- hostPath:
path: <path to docker.jar file> #should be on Minikube VM
type: File
name: testing
When you create docker.jar on VM.
user@nameOfMyVM:~$ pwd
/home/user
user@nameOfMyVM:~$ ls
docker.jar
When you will chage in hostpath.path to /home/user/docker.jar it will return warning
Warning FailedMount 4s (x4 over 7s) kubelet MountVolume.SetUp failed for volume "testing" : hostPath type check failed: /home/sekreta/docker.jar is not a file`
As Kubernetes didn't find this file.
But when you will create this file inside Minikube VM
$ minikube ssh
docker@minikube:~$ pwd
/home/docker
docker@minikube:~$ ls
docker.jar
and change in deployment hostPath.path to /home/docker/docker.jar pod will be created.
$ kubectl get po
NAME READY STATUS RESTARTS AGE
test-c68d959c6-kb275 1/1 Running 0 13s
File can be found in directory set in YAML, which is tmp.
$ kubectl exec -ti test-c68d959c6-kb275 -- bin/bash
root@test-c68d959c6-kb275:/# cd /tmp
root@test-c68d959c6-kb275:/tmp# ls
docker.jar
Conclusion
When you are using HostPath on Minikube you need to remember that filesystem is not your Machine but Minikube VM which was created during minikube start.