In the Kubernetes minikube tutorial there is this command to use Minikube Docker daemon :
$ eval $(minikube docker-env)
What exactly does this command do, that is, what exactly does minikube docker-env
mean?
In the Kubernetes minikube tutorial there is this command to use Minikube Docker daemon :
$ eval $(minikube docker-env)
What exactly does this command do, that is, what exactly does minikube docker-env
mean?
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.
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
One way to figure out what $ eval $(minikube docker-env)
does is to understand that we want to build a docker image in our local machine and then deploy them to the minikube environment.
This command as others have explained makes it easier to do so.
minikube docker-env
minikube docker-env --unset
Without setting your docker configs to minikube env it'll be a bit tedious to build your image locally and run it in a container in your minikube env.
If you have minikube running you can ssh into the env and see all docker images running within it.
You should run this command after running 'minikube start'
eval $(minikube docker-env)
this command let you Connect your cli tool
to docker-env
of Kubernetes cluster