Minikube files do not persist after restart

kubernetesminikube

I'm using minikube version 0.28.0 and files don't persist after a restart.

I ran into the problem after noticing my database data disappears after a restart (even though the pods, pv's, and pvc's say they've been up for days). I used minikube ssh to create some files and noticed those disappear, too.

FWIW – I ran minikube addons list to confirm that default-storageclass is enabled

Should I be using minikube --mount to mount my data to my dev machine's disk? How can I persist my pods' data?

Best Answer

According to the official documentation minikube persists the data stored in the following host directories that can be mapped inside the particular PV via hostPath volume type:

  • /data
  • /var/lib/minikube
  • /var/lib/docker

Hence, in order to mount some custom host folder inside minikube VM, keeping the relevant data to retain across cluster reboots, you can use minikube mount command:

minikube mount [flags] <source directory>:<target directory>