In the Kubernetes minikube tutorial there is this command to use Minikube Docker daemon :
$ eval $(minikube docker-env)
What exactly does this
minikube docker-env
You will see some environment variables
are mentioned there :)
These variables will help your docker CLI (where you write docker commands)
to connect with docker daemon in the VM created by minikube !
Now, to connect your Docker CLI to the docker daemon inside the VM
you need to run : eval $(minikube docker-env)
This will temporarily(for that terminal) connect CLI to docker daemon inside the VM :)
Now, try to do docker ps
, you can see all the containers created inside the VM (will be shown only if you have done some work in k8's cluster)
This is all possible due to those environment variables by docker-env
The command minikube docker-env
returns a set of Bash environment variable exports to configure your local environment to re-use the Docker daemon inside the Minikube instance.
Passing this output through eval
causes bash to evaluate these exports and put them into effect.
You can review the specific commands which will be executed in your shell by omitting the evaluation step and running minikube docker-env
directly. However, this will not perform the configuration – the output needs to be evaluated for that.
This is a workflow optimization intended to improve your experience with building and running Docker images which you can run inside the minikube environment. It is not mandatory that you re-use minikube's Docker daemon to use minikube effectively, but doing so will significantly improve the speed of your code-build-test cycle.
In a normal workflow, you would have a separate Docker registry on your host machine to that in minikube, which necessitates the following process to build and run a Docker image inside minikube:
By re-using the Docker registry inside Minikube, this becomes:
More details of the purpose can be found in the minikube docs.