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?
2
Answers
It’s possible to run more than one minikube cluster at a time. From the minikube FAQ:
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
and see what shell commands they generate. (They’re probably extremely similar.)
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 namedminikube
that can be referenced through-p minikube
or--profile minikube
or simply by omitting the profile. So in practiceminikube -p minikube docker-env
andminikube docker-env
are the same command, butminikube -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. Theeval
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 theminikube
profile is stopped.You can get a list of existing profiles using the following command:
You can run the following commands to better understand the difference between the output when using different profiles.