<p>I'm trying to pull my Docker Image from my private Docker Registry in Kubernetes, but I got this error: ImagePullBackOff</p>
<pre><code>NAME                           READY   STATUS             RESTARTS   AGE
nginx-994fc8fb7-f24sv          2/2     Running            0          2d22h
portals-app-669b654d87-lk258   0/1     ImagePullBackOff   0          66m
portals-app-669b654d87-p87c6   0/1     ImagePullBackOff   0          67m
portals-app-7775d445-c5762     0/1     ImagePullBackOff   0          66m
</code></pre>
<p>So I used describe command to view the error detail, here is the error:</p>
<pre><code>Name:             portals-app-669b654d87-lk258
Namespace:        default
Priority:         0
Service Account:  default
Node:             client-portal-nodepool-qjfch/10.127.0.2
Start Time:       Sat, 25 Feb 2023 20:30:56 +1100
Labels:           app=app
                  pod-template-hash=669b654d87
Annotations:      &lt;none&gt;
Status:           Pending
IP:               10.244.0.60
IPs:
  IP:           10.244.0.60
Controlled By:  ReplicaSet/portals-app-669b654d87
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-api-access-s2j6z:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason   Age                    From     Message
  ----    ------   ----                   ----     -------
  Normal  BackOff  2m34s (x284 over 67m)  kubelet  Back-off pulling image 
&quot;xichen9718/portals_docker_repository:latest&quot;
</code></pre>
<p>I feel this error message is not that clear, and I guess it might have something to do with the Docker Private Registry authentication. So I create an individual Pod. This is my pod Yaml file.:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: xichen9718/portals_docker_repository:latest
  imagePullSecrets:
  - name: regcred
</code></pre>
<p>and I ran the describe command again, I got this at this time:</p>
<pre><code>Name:             private-reg
Namespace:        default
Priority:         0
Service Account:  default
Node:             client-portal-nodepool-qjfch/10.127.0.2
Start Time:       Sat, 25 Feb 2023 21:15:52 +1100
Labels:           &lt;none&gt;
Annotations:      &lt;none&gt;
Status:           Pending
IP:               10.244.0.79
IPs:
  IP:  10.244.0.79
Containers:
  private-reg-container:
    Container ID:
    Image:          xichen9718/portals_docker_repository:latest
    Image ID:
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7gvvj (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-api-access-7gvvj:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                            node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  50s                default-scheduler  Successfully assigned default/private-reg to client-portal-nodepool-qjfch
  Warning  Failed     28s (x2 over 46s)  kubelet            Failed to pull image &quot;xichen9718/portals_docker_repository:latest&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;docker.io/xichen9718/portals_docker_repository:latest&quot;: failed to resolve reference &quot;docker.io/xichen9718/portals_docker_repository:latest&quot;: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
  Warning  Failed     28s (x2 over 46s)  kubelet            Error: ErrImagePull
  Normal   BackOff    15s (x2 over 45s)  kubelet            Back-off pulling image &quot;xichen9718/portals_docker_repository:latest&quot;
  Warning  Failed     15s (x2 over 45s)  kubelet            Error: ImagePullBackOff
  Normal   Pulling    2s (x3 over 49s)   kubelet            Pulling image &quot;xichen9718/portals_docker_repository:latest&quot;
</code></pre>
<p>But I think I set the secret successfully, when I run
<code>kubectl get secret regcred --output=yaml</code>,
I can view my .dockerconfigjson and other data. and I tried to pull the image locally, I can pull it successfully, so that means my image name and tag is correct.
I'm really confused now, can anybody help me with this please?
Thanks a lot.</p>
<p>Update:</p>
<p>I deleted my secret, deployment, pod and re-created them again, then it works. I guess it might have something to do with the sequence of my developing process</p>

xi chen
<p>This:</p>
<pre><code>spec:
  containers:
  - name: private-reg-container
    image: xichen9718/portals_docker_repository:latest
</code></pre>
<p>Is pulling from docker.io and not a private repo.</p>
<p>Also, this:</p>
<pre><code>  Warning  Failed     28s (x2 over 46s)  kubelet            Failed to pull image &quot;xichen9718/portals_docker_repository:latest&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;docker.io/xichen9718/portals_docker_repository:latest&quot;: failed to resolve reference &quot;docker.io/xichen9718/portals_docker_repository:latest&quot;: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
</code></pre>
<p>Says authorization failed. Presumeably because you're trying to authenticate against docker hub and not your private repo.</p>
<p>If you are using a private repo, you need to include the hostname of your repo in the image, e.g.</p>
<pre><code>spec:
  containers:
  - name: private-reg-container
    image: myprivaterepo.com/xichen9718/portals_docker_repository:latest
</code></pre>
<p>If you don't it will assume docker hub</p>
