The command eval $(minikube docker-env) is not working because of error that says "Cannot connect to docker daemon"

6/4/2019

I have started minikube using the following command

minikube start --insecure-registry k8s.gcr.io --insecure-registry registry-1.docker.io --insecure-registry gcr.io --insecure-registry registry.gitlab.com

After it starts I check the status using minikube status and the output is the following

host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.107

Afterwards I run the command eval $(minikube docker-env) so that it can use the docker daemon that minikube is using.

That command runs as is expected. When I check the DOCKER_HOST I get the following value tcp://192.168.99.107:2376

The problem starts when I run a docker command.

For example, when I run docker run hello-world, the command will hang for a while and then I get the following output

docker: error during connect: Post https://192.168.99.107:2376/v1.39/containers/create: Service Unavailable.

One thing you might notice is that the DOCKER_HOST uses TCP will docker run will use HTTPS. I don't know but maybe it might help in getting this issue fixed.

-- TheRealRave
docker
docker-machine
kubernetes
minikube

1 Answer

6/12/2019

HTTPS can run over any reliable stream transport protocol. Normally that's TCP.

1. Check if your image is built.

To run docker images in Kubernetes you can simply use

$ kubectl run hello-world --image=... --port=... --image-pull-policy=...

But you have to set on Docker daemon as well. More information you can find here: docker-daemon

2. Check 2376 port if it is not already in use.

3. Try to run your command as root: Run it as sudo docker ... instead of docker .... The user that you are running as may not have permissions to talk to /var/run/docker.sock on that system.

4. Which version of minikube you use ? In minikube v0.10.0 the --insecure-registry flag is ignored if the machine already existed.). First check if --insecure-registry= is correctly copied into /var/lib/boot2docker/profile in the new VM. You must first minikube delete if you want new flags to be respected.

I hope it helps.

-- MaggieO
Source: StackOverflow