<p>I am unable to deploy an application in kubernetes , this is the deployment yaml.</p>
<pre><code>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: openjdk:14
        ports:
        - containerPort: 8080
        volumeMounts: 
        - name: testing
          mountPath: &quot;/usr/src/myapp/docker.jar&quot;
        workingDir: &quot;/usr/src/myapp&quot;
        command: [&quot;java&quot;]
        args: [&quot;-jar&quot;, &quot;docker.jar&quot;]        
      volumes: 
      - hostPath: 
          path: /home/user/docker.jar
          type: File
        name: testing
</code></pre>
<p>This is the error I receive, and I can verify the file does exist and in this folder.
I tried removing the type but it only uploads an empty directory, it seems to not recognize that the file exists.</p>
<pre><code>MountVolume.SetUp failed for volume &quot;testing&quot; : hostPath type check failed: /home/user/docker.jar is not a file
</code></pre>

Yanir
<p>When you are starting <a href="https://minikube.sigs.k8s.io/docs/" rel="nofollow noreferrer">minikube</a> with default <code>docker</code> driver, you are creating <code>Docker VM</code> inside your machine.</p>
<h3>Background</h3>
<p>When you are using your VM your terminal looks like:</p>
<pre><code>user@nameofyourhost:~$
</code></pre>
<p>But if you will <code>ssh</code> to your <code>Minikube VM</code> terminal looks like below:</p>
<pre><code>docker@minikube:~$ 
</code></pre>
<p>In <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">HostPath</a> you have information:</p>
<blockquote>
<p>A hostPath volume mounts a file or directory from the host node's filesystem into your Pod.</p>
</blockquote>
<p>In <code>minikube</code> when you are using <code>hostPath</code>, node is considered not your <code>machine</code> but the <code>Minikube VM</code> which was created during <code>minikube start</code></p>
<h3>Tests</h3>
<p>As I dont have exactly your files, Ive used <code>nginx</code>. Please remember that you should have proper permissions to directories you want to mount. I've used <code>tmp</code> as in <code>nginx</code> this directory have full access for everyone.</p>
<pre><code>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: &quot;/tmp/docker.jar&quot;   #this is path to the file
      volumes:
      - hostPath:
          path: &lt;path to docker.jar file&gt; #should be on Minikube VM
          type: File
        name: testing
</code></pre>
<p>When you create <code>docker.jar</code> on VM.</p>
<pre><code>user@nameOfMyVM:~$ pwd
/home/user
user@nameOfMyVM:~$ ls
docker.jar
</code></pre>
<p>When you will chage in <code>hostpath.path</code> to <code>/home/user/docker.jar</code> it will return warning</p>
<pre><code>Warning  FailedMount  4s (x4 over 7s)  kubelet            MountVolume.SetUp failed for volume &quot;testing&quot; : hostPath type check failed: /home/sekreta/docker.jar is not a file`
</code></pre>
<p>As Kubernetes didn't find this file.</p>
<p>But when you will create this file inside <code>Minikube VM</code></p>
<pre><code>$ minikube ssh
docker@minikube:~$ pwd
/home/docker
docker@minikube:~$ ls
docker.jar
</code></pre>
<p>and change in deployment <code>hostPath.path</code> to <code>/home/docker/docker.jar</code> pod will be created.</p>
<pre><code>$ kubectl get po
NAME                   READY   STATUS    RESTARTS   AGE
test-c68d959c6-kb275   1/1     Running   0          13s
</code></pre>
<p>File can be found in directory set in YAML, which is <code>tmp</code>.</p>
<pre><code>$ kubectl exec -ti test-c68d959c6-kb275 -- bin/bash
root@test-c68d959c6-kb275:/# cd /tmp
root@test-c68d959c6-kb275:/tmp# ls
docker.jar
</code></pre>
<h3>Conclusion</h3>
<p>When you are using <code>HostPath</code> on <code>Minikube</code> you need to remember that <code>filesystem</code> is not your <code>Machine</code> but <code>Minikube VM</code> which was created during <code>minikube start</code>.</p>
