Reading time ~6 minutes
Docker on MacOS via minikube (2022 edition)
- A Replacement for Docker Desktop
As you might have heard, at the end of January Docker started enforcing the license changes that were announced in August 2021.
Therefore, it was a good time to re-evaluate my setup (overall, I’ve been using Docker Desktop since I started learning about containers in 2017).
In this post, I’m going to document my setup, and how I’ve decided to replace Docker Desktop with minikube on my MacBook.
A Replacement for Docker Desktop
Discussing their pros and cons is not really in scope for this post, nor do I want to swing you towards one or another. In my experience, though, they didn’t feel as “transparent“ in my day-to-day activities as Docker managed to be, as they all required some heavy tweaking to try to resemble the same functionalities offered by Docker for Desktop (emphasis on the “try”).
My main pain points?
- Exposing services to the host.
- Mounting local folders for development, with support for hot-reloading.
- Accessing (registry) credentials from the macOS Keychain.
- Reducing the performance impact on the host.
That’s why, in the end, I’ve decided to switch to minikube.
Although the main purpose of minikube is to allow people to
set up a local Kubernetes cluster,
it can also be used for traditional Docker workflows
It is also worth noting that, even though there are already some tutorials (e.g., 1, 2) describing how to replace Docker Desktop with minikube, it turned out I (like many others) still had issues while trying to mount volumes. After some troubleshooting, I’ve found a solution. The secret? Replace the Hyperkit driver with the Virtualbox one. Why? Because it has built-in host folder sharing.
All of this, without the load of a running Kubernetes cluster!
Next, I’ll describe my setup.
Uninstall Docker Desktop
If you previously had Docker Desktop installed, that’s what needs to be removed:
Install Virtualbox and minikube
Next, you’ll need both Virtualbox and minikube.
For Virtualbox, pre-compiled binaries are available on the official website.
Then, you can use
brew to install minikube,
as well as some other command line utilities (like
Once you have all the prerequisites, you can start minikube:
1 2 3 4 $ minikube start \ --driver=virtualbox \ --memory 4000 --cpus 2 \ --no-kubernetes
2: specifies the driver (
virtualbox) to be used.
3: specifies the amount of memory and CPU to allocate to the virtual machine running in Virtualbox.
--no-kubernetesflag allows to use minikube only as a Docker Desktop replacement without starting Kubernetes itself.
On a first run, the output will look like the one below:
If you open Virtualbox, you’ll be able to see a
minikube virtual machine running:
Subscribe to CloudSecList
The last thing needed is to configure your environment (shell) to use minikube’s Docker daemon:
And that’s it! You won’t even have to make changes to your Dockerfiles or docker-compose files.
Addressing the pain points
|Exposing services to the host||
|Mounting local folders||
|Accessing (registry) credentials from the macOS Keychain||
|Reducing the performance impact on the host||
As a final touch, a couple of tweaks to automate some of the management of minikube.
First, I’ve added the following to my
1 2 eval $(minikube docker-env) alias minikubeup="minikube start --driver=virtualbox --memory 4000 --cpus 2 --no-kubernetes"
1: first, the eval will ensure every new terminal will automatically point to the minikube’s Docker environment.
2: in cases where I’ll have to restart minikube, the
minikubeupalias will allow me to not having to remember the correct flags to use.
Lastly, I’ve added a custom plugin to XBar (a nice utility that allows to put the output from any script or program into your macOS Menu Bar). In this regard, I’ve customised the open source Minikube GUI plugin: I’ve stripped the components related to Kubernetes (not used in my setup), and added options to pause/resume the minikube’s Virtualbox VM:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #!/bin/bash # Adapted from: https://xbarapp.com/docs/plugins/Dev/Kubernetes/minikube.5s.sh.html MINIKUBE_LOGO_COLOR='...' MINIKUBE_LOGO_BW='...' LANG="en_US.UTF-8" PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" export LANG PATH if [[ $(minikube status | grep host) =~ Running ]]; then echo "|image=$MINIKUBE_LOGO_COLOR" else echo "|image=$MINIKUBE_LOGO_BW" fi echo --- while read -r STATUS; do if [[ $STATUS =~ Running ]]; then echo "$STATUS | color=green" echo --- echo "IP: $(minikube ip) | color=black" else echo "$STATUS | color=red" fi done < <(minikube status | grep host) echo --- echo "⭕️ Pause | terminal=true refresh=true shell=VBoxManage param1=controlvm param2=minikube param3=pause param4=&& param5=exit" echo "♻️ Resume | terminal=true refresh=true shell=VBoxManage param1=controlvm param2=minikube param3=resume param4=&& param5=exit" echo ---
15: fetch the status of minikube and show the appropriate icon (coloured or black/white).
22: if minikube is running, show the output of
30: options to pause/resume the minikube’s Virtualbox VM with one click (by leveraging the
VBoxManagecommand line utility).
You can find my adapted version on Github, and a few screenshots below:
In this post, I’ve documented my setup, and how I’ve decided to replace Docker Desktop with minikube on my MacBook.
I can say I’m satisfied with the result, as I was able to maintain a streamlined experience without neither having to change my workflows nor to extensively tweak minikube.
I hope you found this post useful and interesting, and I’m keen to get feedback on it! If you find the information shared was useful, if something is missing, or if you have ideas on how to improve it, please let me know on Twitter.