<p>I'm try to get my local development environment converted from <code>docker-compose</code> to a flavour of lightweight Kubernetes, since our production environments are all Kubernetes (like). With the help of <a href="https://kompose.io" rel="nofollow noreferrer">Kompose</a> I could convert my settings. The part however I struggle with is the conversion of Docker volumes to a local developer machine Volume and Volume claim. Most examples I found cover drivers for S3 or NFS, which isn't what my development laptop offers.</p>
<p>So when I have in my <code>docker-compose.yml</code> a setting like this, what's the local development equivalent in k8s?</p>
<pre class="lang-yaml prettyprint-override"><code>version: &quot;3.6&quot;
services:
  my_test:
    image: &quot;myregistry.com/my_test&quot;
    container_name: &quot;demo&quot;
    hostname: &quot;demo.acme.local&quot;
    stop_grace_period: 120s
    cap_add:
      - SYS_PTRACE
    ports:
      - 80:80
    volumes:
      - my_vol:/local/my_app
volumes:
  my_vol:
    name: &quot;/local/containers/my_app&quot;
    external: false
</code></pre>
<p>I'm &quot;only&quot; looking for the volume part. The rest seems clear.<br />
Help is appreciated</p>

stwissel
<p>Both solutions (<code>hostpath</code> and <code>emptydir</code>) you found looks good.</p>
<p>Here you have documentations to both ones:</p>
<hr />
<blockquote>
<p>A <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer"><code>hostPath</code></a> volume mounts a file or directory from the host node's filesystem into your Pod.</p>
</blockquote>
<p>To the required <code>path</code> property, you can also specify a <code>type</code> for a <code>hostPath</code> volume.</p>
<blockquote>
<p><strong>NOTE</strong>:
HostPath volumes present many security risks, and it is a best practice to avoid the use of HostPaths when possible. When a HostPath volume must be used, it should be scoped to only the required file or directory, and mounted as <strong>ReadOnly</strong>.</p>
</blockquote>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath-configuration-example" rel="nofollow noreferrer"><em>hostPath configuration example</em></a></li>
</ul>
<hr />
<blockquote>
<p>An <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="nofollow noreferrer"><code>emptyDir</code></a> volume is first created when a Pod is assigned to a node, and exists as long as that Pod is running on that node.</p>
</blockquote>
<p><code>EmptyDir</code> volume is initially empty. All containers in the pod have permissions in the <code>emptyDir</code> volume to read and write the same files, despite possibility of diffrent localisations of that volume (it can be mounted at the same or different paths in each container).</p>
<p>In case the Pod is removed from a node for any reason, the data in the <code>emptyDir</code> is deleted <em>permanently</em>.</p>
<blockquote>
<p>Depending on your environment, <code>emptyDir</code> volumes are stored on whatever medium that backs the node such as disk or SSD, or network storage.</p>
</blockquote>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir-configuration-example" rel="nofollow noreferrer"><em>emptyDir configuration example</em></a></li>
</ul>
