Resolved: Converting from docker-compose to Kubernetes – how to deal with volumes on local


I’m try to get my local development environment converted from docker-compose to a flavour of lightweight Kubernetes, since our production environments are all Kubernetes (like). With the help of Kompose 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.
So when I have in my docker-compose.yml a setting like this, what’s the local development equivalent in k8s?
version: "3.6"
    image: ""
    container_name: "demo"
    hostname: "demo.acme.local"
    stop_grace_period: 120s
      - SYS_PTRACE
      - 80:80
      - my_vol:/local/my_app
    name: "/local/containers/my_app"
    external: false
I’m “only” looking for the volume part. The rest seems clear.
Help is appreciated


Both solutions (hostpath and emptydir) you found looks good.
Here you have documentations to both ones:

A hostPath volume mounts a file or directory from the host node’s filesystem into your Pod.

To the required path property, you can also specify a type for a hostPath volume.

NOTE: 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 ReadOnly.

An emptyDir volume is first created when a Pod is assigned to a node, and exists as long as that Pod is running on that node.

EmptyDir volume is initially empty. All containers in the pod have permissions in the emptyDir 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).
In case the Pod is removed from a node for any reason, the data in the emptyDir is deleted permanently.

Depending on your environment, emptyDir volumes are stored on whatever medium that backs the node such as disk or SSD, or network storage.

If you have better answer, please add a comment about this, thank you!


If you like this answer, you can give me a coffee by click here (view Ads)