<p>I'm trying to set up <code>hostPath</code> to share a file between pods.</p>
<p>I'm following this guide <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">Configure a Pod to Use a PersistentVolume for Storage</a>.</p>
<p>Here are the configuration files for <code>pv,pvc,pod</code>.</p>
<p>PV:</p>
<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/tmp/data&quot;
</code></pre>
<p>PVC:</p>
<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>
<p>POD:</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
       claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: &quot;http-server&quot;
      volumeMounts:
      - mountPath: &quot;/usr/share/nginx/html&quot;
        name: task-pv-storage
</code></pre>
<p>I'm adding a file to <code>/tmp/data</code> and but I can't see it in the container.</p>
<p>When I check the status of <code>pv,pvc,pod</code>, the result is as following:</p>
<p><a href="https://i.stack.imgur.com/IpwWx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IpwWx.png" alt="enter image description here" /></a></p>
<p>Can some give me a clue on why I can't see the file? Any suggestion or command on how to debug this kind of issue is welcome.</p>

scott huang
<p><strong>MINIKUBE specific</strong></p>
<p>I was getting the same error when running a local cluster on minikube for Mac.</p>
<p>Minikube actually creates a VM and then runs your containers on it. So the hostPath actually refers to paths inside that VM and not on your local machine. That is why all mounts show up as empty folders.</p>
<p>Solution:</p>
<p>Map your local path to minikube's VM by same name. That way you can refer it as is in you kubernetes Manifests.</p>
<pre><code>minikube mount &lt;source directory&gt;:&lt;target directory&gt;
</code></pre>
<p>In this case:</p>
<pre><code>minikube mount /tmp/data:/tmp/data
</code></pre>
<p>This should do the trick.</p>
<p>SOURCE: <a href="https://minikube.sigs.k8s.io/docs/handbook/mount/" rel="noreferrer">https://minikube.sigs.k8s.io/docs/handbook/mount/</a></p>
