Minikube mount datadir at minikube start

So I actually want to start my minikube cluster with a special directory mounted on it, on /data. This directory contains my db datas.

For this I try:

minikube start \
--driver=docker \
--extra-config=apiserver.service-node-port-range=1-35000 \
--disk-size=5000mb \
--mount \
--mount-string="${PWD}/srcs/mysql/datas:/data"

Actually options --mount and --mount-string="${PWD}/srcs/mysql/datas:/data" doesn't seem to works. No warning or error outputs are displayed but when I connect onto the machine and list files onto /data nothing appears. My directory is not mounted.

If I mount the directory with: minikube mount ${PWD}/srcs/mysql/datas:/data it works and I can list my data in /data. (But I really want to launch it at startup and now what I'm doing wrong).


Posting this community wiki answer to indicate that the issue was resolved by:

I retried it after deleting Minikube configuration folder "~/.minikube" and updated to Minikube v1.19.0 and it works: minikube start --mount --mount-string="$(pwd):/src"


To check on the whole scenario, I've reproduced it with a following setup:

  • Ubuntu 20.04
  • Docker 20.10.7
  • KVM 4.2.1
  • Minikube:
    • v1.22.0 (tested both versions with the same steps)
    • v1.19.0

I'd reckon the issue was resolved not by deleting the ~/.minikube directory or upgrading minikube but rather than with a change to the destination folder that was mounted.

Assuming a following setup:

  • $ mkdir ~/test
  • $ echo "General Kenobi!" > ~/test/hello_there.txt
  • $ minikube start --mount --mount-string ~/test:/data
  • $ minikube ssh
  • $ ls -al /data
total 8
drwxr-xr-x 2 root root 4096 Jul 13 11:45 .
drwxr-xr-x 1 root root 4096 Jul 13 11:45 ..
  • $ minikube start --mount --mount-string ~/test:/src <-- notice the destination change
  • $ minikube ssh
  • $ ls -al /src <-- notice the destination change
total 12
drwxrwxr-x 2 1003 1004 4096 Jul 13 11:42 .
drwxr-xr-x 1 root root 4096 Jul 13 11:47 ..
-rw-rw-r-- 1 1003 1004   16 Jul 13 11:42 hello_there.txt

As it can be seen the files showed correctly when mounted to the directory other than /data.

A side note!

Above scenario was present only with the --driver=docker. --driver=kvm2 mounted the data to /data folder successfully.

This could be related to the persistency of some minikube's directories. More on that can be found here:

  • Minikube.sigs.k8s.io: Docs: Handbook: Persistent Volumes

Another side note!

$ minikube mount with a /data as destination folder worked correctly.


Additional resources:

  • Stackoverflow.com: Questions: Minikube shared volume not shows files after sometime
  • Github.com: Kubernetes: Minikube: Issues: macOS mount: mounted directory is empty