Minikube mount lets you share a directory from your host machine directly into a running Pod, making local development feel just like production.
Let’s see it in action. Imagine you’re developing a web application locally and want to edit its configuration files on your host machine while the Pod uses them.
First, start Minikube if you haven’t already:
minikube start
Now, let’s create a directory on your host that you want to share. We’ll call it my-app-config.
mkdir my-app-config
echo "apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
config.json: |
{
"logLevel": "INFO",
"featureFlags": {
"newUI": true
}
}" > my-app-config/config.json
Next, use the minikube mount command to share this directory with your Minikube cluster. We’ll mount $(pwd)/my-app-config (the absolute path to your local directory) to /etc/app/config inside the Minikube VM.
minikube mount $(pwd)/my-app-config:/etc/app/config
You’ll see output indicating the mount is active. This command essentially tells Minikube to make the contents of your local my-app-config directory accessible at /etc/app/config within the Minikube VM.
Now, let’s create a simple Pod that will use this mounted directory. We’ll deploy a basic Nginx pod and configure it to serve files from a volume that points to our mount.
Create a file named pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: web-server
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: config-volume
mountPath: /usr/share/nginx/html # Nginx's default web root
volumes:
- name: config-volume
emptyDir: {} # We'll use a trick here to link to the host mount
The emptyDir volume is a placeholder. The magic happens because Minikube, when it sees a minikube mount active, will automatically bind mount the specified host directory into the Pod’s volume if the volume is named appropriately or if you use specific annotations (though minikube mount is designed to be simpler). In this scenario, Minikube’s mount command establishes a persistent connection. When a Pod requests access to a path that overlaps with a mounted directory, Minikube’s underlying mechanisms ensure that the host directory is presented to the Pod.
Let’s deploy this Pod:
kubectl apply -f pod.yaml
Now, let’s create a simple index.html in our my-app-config directory to demonstrate.
echo "<h1>Hello from my local config!</h1>" > my-app-config/index.html
Wait a few moments for the Pod to start, then get its IP address:
kubectl get pod web-server -o wide
You’ll see an IP address for the web-server pod. Access it in your browser: http://<pod-ip>. You should see "Hello from my local config!".
If you edit my-app-config/index.html on your host machine, the changes will be reflected almost immediately when you refresh the browser.
The core problem this solves is the disconnect between local development workflows and Kubernetes deployments. Developers often want to iterate on configuration files, static assets, or even code without rebuilding container images or restarting Pods. minikube mount bridges this gap by providing a live, bidirectional sync. It’s not just copying files; it’s a true filesystem mount.
The mechanism behind minikube mount involves Minikube’s underlying VM. When you run minikube mount, Minikube sets up a shared filesystem between your host OS and the Minikube VM. This is typically achieved using mechanisms like virtiofs or sshfs, depending on your Minikube driver and operating system. Kubernetes then sees this mounted directory within the VM and makes it available to Pods via volumes. Changes on your host are propagated to the VM, and thus to the Pod.
A common point of confusion is that minikube mount is not a Kubernetes native feature but a Minikube-specific convenience. It’s designed to work seamlessly with kubectl and Pods running within Minikube. The mountPath in your Pod definition is where the mounted directory will appear inside the container, not where it’s mounted in the Minikube VM itself. Minikube handles the translation.
The most surprising thing about minikube mount is that it often works bidirectionally with surprising robustness, allowing modifications made within the Pod (if the container process writes to the mounted directory) to be reflected back on your host filesystem. This is a powerful, albeit sometimes overlooked, feature for scenarios where a Pod might generate logs or output files that you want to capture directly on your host.
After you’re done, remember to stop the mount:
minikube stop mount
The next hurdle is understanding how to manage persistent storage beyond simple local mounts, such as using Minikube’s support for different StorageClass configurations.