Kobi Rosenstein
1 min readDec 24, 2023

--

Connection timed out while pulling an image in Minikube

It’s been a long time coming, but I’m finally getting my feet wet with Kubernetes.
Naturally the easy way to start is with minikube. However, I got hit with a super frustrating issue right away — when running

kubectl run nginx --image=nginx

I got this error:

Warning Failed 1s (x2 over 50s) kubelet Failed to pull image "nginx": Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Warning Failed 1s (x2 over 50s) kubelet Error: ErrImagePull

If I ran a simple

docker pull nginx
minkikube ssh

on my laptop, it worked.

To debug, I used

minukube ssh

where I tried to run the docker pull — and got a timeout.

I don’t know what the actual issue was, but changing the file /etc/resolv.conf from within Minikube, from a nameserver entry containing my laptop’s IP address, to a normal DNS server, worked.
Here is a command to automatically apply this setting immediately after running minikube start:

docker exec -d $(docker ps | grep minikube | awk '{print $1}') bash -c "echo nameserver DNS_SERVER_IP >> /etc/resolv.conf"

Make sure to change DNS_SERVER_IP to a real value, like 8.8.8.8, or maybe your company DNS server.

--

--

Kobi Rosenstein

Linux infrastructure guy. This blog chronicles my “gotcha” moments — Each post contains an answer I would have like to have found when trawling google.