How to use Docker Hub private repos at GKE?

2/11/2019

I am migrating a huge cloud cluster from AWS to GKE. But I am having trouble authenticating with Docker Hub, I keep getting Failed to pull image "myorg/mycontainer": rpc error: code = Unknown desc = Error response from daemon: repository myorg/mycontainer not found: does not exist or no pull access

It seems that the way to authenticate gcloud with docker has recently changed, so whats the proper way of tdoint this?

-- CESCO
containers
dockerhub
google-kubernetes-engine

1 Answer

2/13/2019

You have to pass your docker hub login credentials as a secret

kubectl create secret docker-registry myregistrykey --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL

where --docker-server=https://index.docker.io/v1/

Now, you can create pods which reference that secret by adding an imagePullSecrets section to a pod definition.

kind: Pod
metadata:
  name: foo
  namespace: awesomeapps
spec:
  containers:
    - name: foo
      image: janedoe/awesomeapp:v1
  imagePullSecrets:
    - name: myregistrykey```
-- satya
Source: StackOverflow