<p>I have created a deployment and I wanted to mount the host path to the container, and when I check the container I see only empty folder.</p>
<p>Why am I getting this error? What can be the cause?</p>
<p>EDIT: I am using Windows OS.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
 name: myservicepod6
 labels:
  app: servicepod
spec:
 replicas: 1
 selector:
  matchLabels:
   app: servicepod
 template:
  metadata:
    labels:
     app: servicepod
  spec:
   containers:
   - name: php
     image: php:7.2-apache
     command: [&quot;/bin/sh&quot;, &quot;-c&quot;]
     args: [&quot;service apache2 start; sleep infinity&quot;]
     ports:
      - name: serviceport
        containerPort: 80
     volumeMounts:
      - mountPath: /var/www/html/
        name: hostvolume

   volumes:
    - name: hostvolume
      hostPath:
        path: /C/Users/utkarsh/pentesting/learnings/kubernetes/app/objectmanagement/deployments/src/*

</code></pre>
<p>EDIT FOR THE ANSWER -</p>
<p>I start the minkube - <code> minikube start --mount-string=&quot;$HOME/test/src/code/file:/data&quot;</code></p>
<p>Then I changed the deployment file like below</p>
<p>Showing only volume part</p>
<pre><code>  spec:
   volumes:
   - name: hostvolume
     hostPath:
      path: /C/Users/utkarsh/pentesting/learnings/kubernetes/app/deployments/src
   containers:
   - name: php
     image: php:7.2-apache
     command: [&quot;/bin/sh&quot;, &quot;-c&quot;]
     args: [&quot;service apache2 start; sleep infinity&quot;]
     ports:
      - name: serviceport
        containerPort: 80
     volumeMounts: 
      - name: hostvolume
        mountPath: /test/src/code/file
</code></pre>
<p>When I log into the pod and went to the directory (/test/src/code/file) I found the directory empty</p>
<p>let me know what am I missing?</p>

<p>After a detailed search and hit and trial method - Found the way</p>
<p>Only for minikube:-</p>
<p>First we need to mount the host folder into the directory name:</p>
<p><code>minikube mount src/:/var/www/html</code></p>
<p>Then we need to define hostPath and mountPath as</p>
<p><code>/var/www/html</code></p>
<p>Because now we have mount the folder to html folder.</p>
<pre><code>volumes:
   - name: hostvolume
     hostPath:
      path: /var/www/html
   containers:
   - name: php
     image: php:7.2-apache
     command: [&quot;/bin/sh&quot;, &quot;-c&quot;]
     args: [&quot;service apache2 start; sleep infinity&quot;]
     workingDir: /var/www/html
     ports:
      - name: serviceport
        containerPort: 80
     volumeMounts: 
      - name: hostvolume
        mountPath: /var/www/html

</code></pre>
