2

I've set up the Docker Engine locally to run on minikube (rather than using Docker Desktop). I know that I need to make sure that the Engine "talks to" the minikube cluster. I've consulted two tutorials, which have slightly different instructions. Specifically for this question, I want to understand the difference between the command:

eval $(minikube -p minikube docker-env)

referenced here, and

eval $(minikube docker-env)

referenced here. What does the profile flag -p do in this case?

whoopscheckmate
  • 746
  • 8
  • 23

2 Answers2

3

Minikube profiles are a way of getting different isolated environments (VMs), which can be helpful in a handful of scenarios (testing how the application behaves on different networks, testing different K8s versions, etc).

By default, the minikube start will start a VM with a profile named minikube that can be referenced through -p minikube or --profile minikube or simply by omitting the profile. So in practice minikube -p minikube docker-env and minikube docker-env are the same command, but minikube -p otherkube docker-env points to a different profile.

The command minikube -p <profile> docker-env prints out a set of environment variables that when evaluated will allow your local docker commands to point to the docker agent inside the specified profile's VM. The eval command will run these exports in the current shell. Setting different profiles will change slightly some of the variables (namely the docker host and the active docker daemon VM).

The minikube -p <profile> docker-env will fail if the specified profile is stopped. In the same way, minikube docker-env will fail if the minikube profile is stopped.

You can get a list of existing profiles using the following command:

minikube profile list

You can run the following commands to better understand the difference between the output when using different profiles.

minikube -p minikube start
minikube -p otherkube start
minikube docker-env
minikube -p minikube docker-env
minikube -p otherkube docker-env
rph
  • 2,104
  • 2
  • 13
  • 24
2

It's possible to run more than one minikube cluster at a time. From the minikube FAQ:

By default, minikube start creates a cluster named “minikube”. If you would like to create a different cluster or change its name, you can use the --profile (or -p) flag, which will create a cluster with the specified name. Please note that you can have multiple clusters on the same machine.

So the minikube -p minikube option is just explicitly naming the default minikube cluster. If you're only running one (probably the common case) it's safe to omit it.

With both of these commands, you also might try just running the commands, without evaluating their output

minikube docker-env
minikube -p minikube docker-env

and see what shell commands they generate. (They're probably extremely similar.)

David Maze
  • 130,717
  • 29
  • 175
  • 215