Image Pullback Issues

Log in to Docker

docker login

When prompted, enter your Docker username and password.

The login process creates or updates a config.json file that holds an authorization token.

View the config.json file:

cat ~/.docker/config.json

The output contains a section similar to this:

{ "auths": { "https://index.docker.io/v1/": { "auth": "c3R...zE2" } } }

Note: If you use a Docker credentials store, you won't see that auth entry but a credsStore entry with the name of the store as value

Create a Secret based on existing Docker credentials

A Kubernetes cluster uses the Secret of kubernetes.io/dockerconfigjson type to authenticate with a container registry to pull a private image.

If you already ran docker login, you can copy that credential into Kubernetes:

kubectl create secret generic regcred --from-file=.dockerconfigjson=/home/hcmlxadmin/.docker/config.json --type=kubernetes.io/dockerconfigjson

Create a Pod Deployment

nano testpod.yml
apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: nginx
  imagePullSecrets:
  - name: regcred

Save the file

kubectl apply -f testpod.yml
kubectl get pod private-reg

Last updated

Was this helpful?