How to pull image from dockerhub in kubernetes?

Snipper03 picture Snipper03 · Feb 28, 2018 · Viewed 36k times · Source

I am planning to deploy an application in my kubernetes-clustering infra. I pushed image to dockerhub repo. How can I pull image from dockerhub?

Answer

Bill Hegazy picture Bill Hegazy · Sep 22, 2018

One line command to create a Docker registry secret

kubectl create secret docker-registry regcred --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email> -n <your-namespace>

Then you can use it in your deployment file under spec

spec:
  containers:
  - name: private-reg-container-name
    image: <your-private-image>
  imagePullSecrets:
  - name: regcred

More details: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token