Unable to pull from private docker hub registry on kubernetes

5/24/2017

I'm running a k8 cluster on google container engine. I'm having trouble getting it to pull images from a private docker repo.

I get the following when trying to boot:

Name:  ds-expected-date
Namespace: default
Node:  gke-ds-cluster-1-default-pool-8980b100-l64j/10.132.0.3
Start Time: Wed, 24 May 2017 13:24:11 +0100
Labels:  <none>
Annotations: kubernetes.io/limit-ranger=LimitRanger plugin set: cpu request for container ds-expected-date-flask
Status:  Pending
IP:  10.40.0.23
Controllers: <none>
Containers:
  ds-expected-date-flask:
    Container ID:
    Image:  fluidy/ds-expected-date:latest
    Image ID:
    Port:
    State:  Waiting
      Reason:  ImagePullBackOff
    Ready:  False
    Restart Count: 0
    Requests:
      cpu:  100m
    Environment: <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-h340m (ro)
Conditions:
  Type  Status
  Initialized  True
  Ready  False
  PodScheduled  True
Volumes:
  default-token-h340m:
    Type: Secret (a volume populated by a Secret)
    SecretName: default-token-h340m
    Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: <none>
Events:
  FirstSeen LastSeen Count From       SubObjectPath    Type  Reason  Message
  --------- -------- ----- ----       -------------    -------- ------  -------
  21s  21s  1 default-scheduler          Normal  Scheduled Successfully assigned ds-expected-date to gke-ds-cluster-1-default-pool-8980b100-l64j
  18s  18s  1 kubelet, gke-ds-cluster-1-default-pool-8980b100-l64j spec.containers{ds-expected-date-flask} Normal  BackOff  Back-off pulling image "fluidy/ds-expected-date:latest"
  18s  18s  1 kubelet, gke-ds-cluster-1-default-pool-8980b100-l64j      Warning  FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ds-expected-date-flask" with ImagePullBackOff: "Back-off pulling image \"fluidy/ds-expected-date:latest\""

  20s 6s 2 kubelet, gke-ds-cluster-1-default-pool-8980b100-l64j spec.containers{ds-expected-date-flask} Normal Pulling  pulling image "fluidy/ds-expected-date:latest"
  19s 5s 2 kubelet, gke-ds-cluster-1-default-pool-8980b100-l64j spec.containers{ds-expected-date-flask} Warning Failed  Failed to pull image "fluidy/ds-expected-date:latest": Error response from daemon: unauthorized: authentication required
  19s 5s 2 kubelet, gke-ds-cluster-1-default-pool-8980b100-l64j      Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ds-expected-date-flask" with ErrImagePull: "Error response from daemon: unauthorized: authentication required"

I have followed all the instructions on the docs page. I'm confident my registry secret is being read - if I put duff credentials in it, the error changes to 'invalid user name or password'.

-- Dom Barker
dockerhub
google-kubernetes-engine
kubernetes

1 Answer

6/5/2017

You have not configured your cluster to pull private images from Docker Hub with your credentials.

Read and apply this guide: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

Google Container Engine can automatically pull from Google Container Registry (http://gcr.io), consider using that without pulling images from a private registry.

-- AhmetB - Google
Source: StackOverflow