Setting up a VS Code Dev Container - minikube

Oct 13, 2021 · 3 min read

This post builds on what we already learnt in Setting up a VS Code Dev Container. It’s more specific goal is to discuss running Dev Containers whilst using minikube as a Docker Desktop replacement on the Mac.

There is lots of chatter about the new license for Docker Desktop. The license changes impacts the business I work for. I wanted to know what our options were.

Getting minikube as a drop in replacement for Docker Desktop on the Mac, was relatively straight forward.

Some good articles to read:

Recap on getting minikube working

I first had to uninstall Docker Desktop. Once this was done, I used to install the necessary packages.

brew install hyperkit
brew install minikube
brew install docker
brew install docker-compose

I had previously been using minikube, so I had to delete the old config. If you have never used minikube before, or you’re happy with your existing config, then ignore the following command.

rm ~/.minikube/config/config.json

Once this was complete, I could start the minikube application.

minikube start

Now we need to get Docker talking to minikube

eval $(minikube -p minikube docker-env)

This command populates the following environment variables (as of the time of writing):

If you’re going to be using minikube going forward, you’re going to want the eval command in your dotfiles (.bashrc, or .zshrc, etc). This means you don’t need to manually remember to perform the command each time you want to use Docker in a new shell.

Now we need the docker url in our hosts file:

echo "`minikube ip` docker.local" | sudo tee -a /etc/hosts > /dev/null

At this point, running docker run hello-world should run the container.

minikube and VS Code Dev Containers

If you are use to running VS Code Dev Containers, you know that it will build the image, and then run the container before updating your VS Code.

The first time I did this after switching to minikube I got the following error:

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: <path to project>

This is because Docker is trying to interact with the Hyperkit VM. Therefore, we need to share our project (from the host) into the Hyperkit VM.

minikube mount "$(pwd)":"$(pwd)"

You will need to keep this process running whilst you want to use VS Code Dev Containers.

Once you’ve run the mount command, you can restart your Dev Container, and it should be working fine.


Docker Desktop is certainly more developer friendly. You install it, and you can kind of forget about it. If you’re migrating to minikube there is a little up front work, that can be easily automated. Once it is done, again, you can kind of forget about it. It’s also a gateway into Kubernetes, if that is where your path is taking you.

See also