So, my team is using Kubernetes for deploying a complex app in a developer environment on our desktop. We use the Kubernetes (“k8s”) built into Docker Desktop.
We need persistent storage, so we use a PersistentVolume with local-storage type. Initially, we thought we should put our data directory in a well-known directory, like
/usr/local/ . But when we tried to use the PersistentVolume from a Deployment, the pods were always stuck in ContainerCreating status, and the event log said the directory did not exist.
Suspecting some kind of permissions issue, I eventually tried pointing the PersistentVolume to a subdirectory of my own home directory,
/Users/evan/<ourappname> . It worked; we could get everything running. After asking on Mastodon, I got a helpful response from Francis Augusto sending a link to show that because it runs in a Linux VM, Docker Desktop is restricted in which files you can use.
But because we’re using shared k8s configuration files in our Git repo, we didn’t want to include anyone’s username in our config files.
So, it turns out, there’s a way to make it work! There’s a special directory on Mac computers for sharing data among all users: /Users/Shared. We set up our PersistentVolume to use
/Users/Shared/<ourapp>/ , and it seems to work just fine.
A word of warning: that directory is available to every user account on the Mac. So if more than one person uses your computer, and you don’t want them to see the files in your PersistentVolume, put them somewhere else.
I hope that’s helpful for other teams using k8s for developer environments on Docker Desktop for Mac.
2 thoughts on “PersistentVolume on Docker Desktop for Mac”
Have you tried podman desktop? https://podman-desktop.io/
I’ve been using podman exclusively for a while now quite successfully. I’d love to hear your thoughts on it if/when you try it.
Hi Craig! I’ll take a look. Great to see another tool in the market.