Minikube and Docker - conflict?

3/25/2019

I've been using Docker for quite a while for some development. Now, I am trying to learn some more advanced stuff using Kubernetes.

In some course I found information that I should run

eval $(minikube docker-env)

That would register a few environmental variables: DOCKER_TLS_VERIFY, DOCKER_HOST, DOCKER_CERT_PATH and DOCKER_API_VERSION. What would it do? Wouldn't that break my day to day work on default values with my host?

Also, is it possible to switch context/config for my local Docker somehow similar to kubectl config use-context?

-- Tomasz Kapłoński
docker
kubernetes
minikube

2 Answers

3/25/2019

The said command will only manipulate the current shell. Opening up a new one will allow you to continue working with your normal workflow as the docker CLI will for example per default connect to the daemon socket at /var/run/docker.sock.

I don't know of a tool that will allow you to switch those settings with a single command and based on a context name as kubectl allows you to. You could however write an alias. For bash you could for example just execute:

$ echo 'alias docker-context-a="eval \$(minikube docker-env)"' >> ~/.bashrc
-- Arne
Source: StackOverflow

3/25/2019

That command points Docker’s environment variables to use a Docker daemon hosted inside the Minikube VM, instead of one running locally on your host or in a Docker Desktop-managed VM. This means that you won’t be able to see or run any images or Docker-local volumes you had before you switched (it’s a separate VM). In the same way that you can $(minikube docker-env) to “switch to” the Minkube VM’s Docker, you can $(minikube docker-env -u) to “switch back”.

Mostly using this actually only makes sense if you’re on a non-Linux host and get Docker via a VM; this lets you share the one Minikube/Docker VM and not have to launch two separate VMs, one for Docker and one not.

If you’re going to use Minikube, you should use it the same way you’d use a real, remote Kubernetes cluster: set up a Docker registry, docker build && docker push images there, and reference it in your Deployment specs. The convolutions to get things like live code reloading in Kubernetes are tricky, don’t work on any other Kubernetes setup, and aren’t what you’d run in production.

-- David Maze
Source: StackOverflow