<p>I am looking to do local dev of an app that is running in Kubernetes on minikube. I want to mount a local directory to speed up development, so I can make code changes to my app (python) without rebuilding the container.</p>
<p>If I understand correctly, I have two out of the box options:</p>
<ol>
<li><a href="https://minikube.sigs.k8s.io/docs/handbook/mount/" rel="nofollow noreferrer">9P mount</a> which is provided by minikube</li>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">hostPath mount</a> which comes directly from Kubernetes</li>
</ol>
<p>What are the differences between these, and in what cases would one be appropriate over the other?</p>

<p><a href="https://minikube.sigs.k8s.io/docs/handbook/mount/#9p-mounts" rel="nofollow noreferrer">9P mount</a> and <a href="https://minikube.sigs.k8s.io/docs/handbook/persistent_volumes/" rel="nofollow noreferrer">hostPath</a>  are two different concepts. You cannot mount directory to pod using 9P mount.</p>
<p>9P mount is used to mount host directory into the minikube VM.</p>
<p>HostPath is a persistent volume which mounts a file or directory from the host node's(in your case minikube VM) filesystem into your Pod.</p>
<p>Take a look also on types of Persistent Volumes: <a href="https://www.google.com/url?q=https://kubernetes.io/docs/concepts/storage/persistent-volumes/%23types-of-persistent-volumes&amp;sa=D&amp;source=hangouts&amp;ust=1604583607939000&amp;usg=AFQjCNHDuPV6-f5R7hLBJD0pSU1vJS5wRQ" rel="nofollow noreferrer">pv-types-k8s</a>.</p>
<p><strong>If you want to mount a local directory to pod:</strong></p>
<p>First, you need to mount your directory  for example: <code>$HOME/your/path</code>  into your minikube VM using <a href="https://minikube.sigs.k8s.io/docs/handbook/mount/" rel="nofollow noreferrer">9P</a>. Execute command:</p>
<pre><code>$ minikube start --mount-string=&quot;$HOME/your/path:/data&quot;

</code></pre>
<p>Then if you mount  <code>/data</code>  into your Pod using <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume" rel="nofollow noreferrer">hostPath</a>, you will get you local directory data into Pod.</p>
<p><strong>Another solution</strong>:</p>
<p>Mount host's  <code>$HOME</code>  directory  into minikube's  <code>/hosthome</code>  directory. Get your data:</p>
<pre><code>$ ls -la /hosthome/your/path
</code></pre>
<p>To mount this directory, you have to just change your Pod's hostPath</p>
<pre><code>hostPath:
  path: /hosthome/your/path
</code></pre>
<p>Take a look: <a href="https://stackoverflow.com/questions/48534980/mount-local-directory-into-pod-in-minikube">minikube-mount-data-into-pod</a>.</p>
<p>Also you need to know that:</p>
<blockquote>
<p>Minikube is configured to persist files stored under the following
directories, which are made in the Minikube VM (or on your localhost
if running on bare metal). You may lose data from other directories on
reboots.</p>
</blockquote>
<p>More: <a href="https://minikube.sigs.k8s.io/docs/handbook/persistent_volumes/#a-note-on-mounts-persistence-and-minikube-hosts" rel="nofollow noreferrer">note-persistence-minikube</a>.</p>
<p>See <a href="https://minikube.sigs.k8s.io/docs/handbook/mount/#driver-mounts" rel="nofollow noreferrer">driver-mounts</a> as an alternative.</p>
