run `minikube start`, cannot pull k8s.gcr images, but `docker pull` can do

2/21/2019

I am try run k8s via minikube, I follow the offical article, when I try the command of minikube start, The error said I cannot pull the docker images(k8s.gcr):

tianyu@ubuntu:~$ minikube start
  minikube v0.34.1 on linux (amd64)
  Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
  "minikube" IP address is 192.168.99.100
  Found network options:
HTTP_PROXY=http://127.0.0.1:35033
HTTPS_PROXY=http://127.0.0.1:35033/
NO_PROXY=localhost,127.0.0.0/8,::1
  Configuring Docker as the container runtime ...
✨  Preparing Kubernetes environment ...
  Pulling images required by Kubernetes v1.13.3 ...
❌  Unable to pull images, which may be OK: running cmd: sudo kubeadm config images pull --config /var/lib/kubeadm.yaml: command failed: sudo kubeadm config images pull --config /var/lib/kubeadm.yaml
stdout: 
stderr: failed to pull image "k8s.gcr.io/kube-apiserver:v1.13.3": output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
: Process exited with status 1
  Launching Kubernetes v1.13.3 using kubeadm ... 
  Error starting cluster: kubeadm init: 
sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data-minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI 

[init] Using Kubernetes version: v1.13.3
[preflight] Running pre-flight checks
    [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
    [WARNING Swap]: running with swap on is not supported. Please disable swap
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
    [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
    [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-scheduler:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
....
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

: Process exited with status 1

I'm in china, so I access the gcr docker hub by a vpn. I followed this link(https://docs.docker.com/config/daemon/systemd/#httphttps-proxy), so I can pull images(k8s.gcr) by docker. The infos are following:

tianyu@ubuntu:~$ sudo docker pull k8s.gcr.io/kube-apiserver:v1.13.3
v1.13.3: Pulling from kube-apiserver
73e3e9d78c61: Pull complete 
d261e2f8ca5b: Pull complete 
Digest: sha256:cdb80dc78f3c25267229012a33800b8b203e8e8b9fa59f9fe93e156cc859f89c
Status: Downloaded newer image for k8s.gcr.io/kube-apiserver:v1.13.3
tianyu@ubuntu:~$ sudo docker pull k8s.gcr.io/kube-controller-manager:v1.13.3
v1.13.3: Pulling from kube-controller-manager
73e3e9d78c61: Already exists 
846fc1deb4d7: Pull complete 
Digest: sha256:408350880946f037be82d6ad2ed7dc3746b221932f0eeb375aef935d62392031
Status: Downloaded newer image for k8s.gcr.io/kube-controller-manager:v1.13.3

Why I cannot pull images via minikube?

thanks for your time.

-- Julius Wang
docker
kubernetes
minikube

4 Answers

3/25/2020

If you are using mac, following will work. minikube start --vm-driver=virtualbox You will have to download and install VirtualBox for this first.

-- Ankit Patil
Source: StackOverflow

12/16/2019

--register-mirror=registry.cn-hangzhou.aliyuncs.com/google_containers does not work for me. And --image-mirror-country=cn too.

But --docker-env HTTP_PROXY=http://10.0.2.2:35033 --docker-env HTTPS_PROXY=http://10.0.2.2:35033 works for me.

It is really strange that I have proxy configured. i can ping through google.com. But can not pull images directly.

-- MichaelWang
Source: StackOverflow

3/29/2019

Minikube 1.0 releases in March 2019 now officially includes:

Add --image-repository flag so that users can select an alternative repository mirror

This follow PR 3714

This PR is aiming to support a new command line argument --image-repository for some users which has difficulty accessing gcr.io.

It was tested with withregistry.cn-hangzhou.aliyuncs.com/google_containers.

This is one of the well known mirrors for gcr.io maintained by Aliyun guys.
I verified with this mirror so it should work as expected (v1.13.3).

We may use --image-repository as an ultimate workaround if none of mirrors provided is accessible in user's environment.
I agree that maintaining a mirror list as like the APT / pacman world also helps, or even trying to guess a reliable mirror by IP address during the setup.

--registry-mirror only impacts those images with no repository prefix - images that come from the Docker official registry.
It won't work on images from private registries, which is the case like gcr.io/kube-proxy. For private images, docker will still go to the private registry and fetch them.

If you set up minikube with --registry-mirror, it could work for pods/deployments that use ubuntu/18.04, but not for gcr.io/ - you will need to wipe the "gcr.io/" out from the references to make it look like an image from the official registry.
For the latter case, it could be achieved using --registry-mirror https://private_server --image-registry [private_server/]google_containers

-- VonC
Source: StackOverflow

2/23/2019

I'm in china too.Pls use the params to start minikube

--docker-env HTTP_PROXY=http://10.0.2.2:35033 --docker-env HTTPS_PROXY=http://10.0.2.2:35033
-- cisiqo
Source: StackOverflow