How I Work: Using Minikube Instead of Docker Desktop

Published: Thursday, 9 September 2021 by Michael Twomey

The Problem

I don’t want to use Docker Desktop to run containers on my Mac. I also want to run Kubernetes stuff and I want to use a more CLI oriented tool.

A Solution: minikube

I’ve been using minikube for a while now, it’s worked perfectly as a means to run containers on my Mac. As a bonus you can also run Kubernetes pods :D

It’s 99% identical to running Docker Desktop (it runs a VM and your docker commands act on that VM). The only real difference is in my setup I don’t run any kind of localhost proxy, so you connect to the VM’s IP instead of localhost for accessing services.

Installation

  1. Uninstall Docker Desktop if you have it.

    Unset any docker env vars except for DOCKER_BUILDKIT=1 (if you have that set)

  2. brew install docker minikube (the docker here is the CLI tool, not the full stack)

  3. minikube start

    This will take quite a while the first time but should result in a working minikube (with your config pointing to it).

  4. Run minikube docker-env to get instructions for setting up Docker to point to minikube. Typically this is a bunch of environment variables to set in your shell.

  5. docker ps and docker run hello-world

Optional Extra: Using VirtualBox

I like to use VirtualBox instead of the default driver. One reason is I more easily peak into the VM and another is to work around macos hyperkit NAT mode network (VPN share issue) #273 which screws up talking to my work VPN.

To install:

  1. brew install docker minikube like above.

  2. Install VirtualBox from https://www.virtualbox.org

    Do not install the VirtualBox extensions if prompted, they’re not needed for this and they require a licence for commercial use.

    Why install directly instead of via Homebrew? It’s the kernel extension, every time homebrew updates VirtualBox it breaks your minikube until you reboot. I find it easier (and less annoying) to upgrade more slowly by hand.

  3. minikube stop if you’ve it before reading about this Virtualbox option.

  4. minikube delete to expunge the previous setup.

  5. Reconfigure minikube to use VirtualBox instead:

    minikube config set driver virtualbox
    minikube config set cpus 2
    minikube config set disk-size 60GB  # Disk space for all those docker builds!
    minikube config set memory 8192  # Good on a 16GB or 32GB machine
    
  6. minikube start

  7. You may need to run minikube docker-env again to reconfigure your settings

  8. Use minikube ip to locate the IP services listen on.

    e.g. docker run --rm -it -p 6379:6379 redis will wind up listening on $(minikube ip):6379

Bonus: podman

You can also run podman with this setup, which is ideal for trying it out.

To set it up use brew install podman and minikube podman-env.