Search code examples
dockerevalminikubedocker-engine

Command `eval $(minikube docker-env)` vs `Using eval $(minikube -p minikube docker-env)`


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?


Solution

  • 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