<p>When trying to run a pod that uses docker image from a private docker registry. I am getting the following error:</p>
<pre><code>Warning  Failed     24s (x2 over 40s)  kubelet, minikube  Failed to pull image &quot;registry.hub.docker.com/repository/docker/projecthelloworld/helloworld-container:V1&quot;: rpc error: code = Unknown desc = Error response from daemon: unauthorized: authentication required
</code></pre>
<p>In order to find if there is any issue with the credentials, I tried to check the secret with the name <code>regcred</code> but I am not getting any output, which might be the reason why I am getting the authentication error.</p>
<pre><code>k get secret regcred -o=&quot;jsonpath={.data .dockerconfigjson}&quot;
</code></pre>
<p>This is how I created the secret <code>regcred</code> and the applied it:</p>
<pre><code>kubectl create secret docker-registry --dry-run=client regcred \
--docker-server=https://index.docker.io/v1/ \
--docker-username=projecthelloworld \
--docker-password=HelloWorld240721 \
--docker-email=hello.world@gmail.com \
-o yaml &gt; docker-secret.yaml
</code></pre>
<p>Here is the generated <code>docker-secret.yaml</code> is</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsidXNlcm5hbWUiOiJwcm9qZWN0aGVsbG93b3JsZCIsInBhc3N3b3JkIjoiSGVsbG9Xb3JsZDI0MDcyMSIsImVtYWlsIjoiaGVsbG8ud29ybGRAZ21haWwuY29tIiwiYXV0aCI6ImNISnZhbVZqZEdobGJHeHZkMjl5YkdRNlNHVnNiRzlYYjNKc1pESTBNRGN5TVE9PSJ9fX0l
kind: Secret
metadata:
  creationTimestamp: null
  name: regcred
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>Output of secret <code>k get secret regcred -o yaml</code></p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsidXNlcm5hbWUiOiJwcm9qZWN0b3JjYSIsInBhc3N3b3JkIjoiT3JjYTI0MDcyMSIsImVtYWlsIjoic3VyZXNoLnNoYXJtYUB0aGViaWdzY2FsZS5jb20iLCJhdXRoIjoiY0hKdmFtVmpkRzl5WTJFNlQzSmpZVEkwTURjeU1RPT0ifX19
kind: Secret
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {&quot;apiVersion&quot;:&quot;v1&quot;,&quot;data&quot;:{&quot;.dockerconfigjson&quot;:&quot;eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsidXNlcm5hbWUiOiJwcm9qZWN0b3JjYSIsInBhc3N3b3JkIjoiT3JjYTI0MDcyMSIsImVtYWlsIjoic3VyZXNoLnNoYXJtYUB0aGViaWdzY2FsZS5jb20iLCJhdXRoIjoiY0hKdmFtVmpkRzl5WTJFNlQzSmpZVEkwTURjeU1RPT0ifX19&quot;},&quot;kind&quot;:&quot;Secret&quot;,&quot;metadata&quot;:{&quot;annotations&quot;:{},&quot;creationTimestamp&quot;:null,&quot;name&quot;:&quot;regcred&quot;,&quot;namespace&quot;:&quot;default&quot;},&quot;type&quot;:&quot;kubernetes.io/dockerconfigjson&quot;}
  creationTimestamp: &quot;2021-08-21T03:18:14Z&quot;
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:.dockerconfigjson: {}
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
      f:type: {}
    manager: kubectl-client-side-apply
    operation: Update
    time: &quot;2021-08-21T03:18:14Z&quot;
  name: regcred
  namespace: default
  resourceVersion: &quot;71712&quot;
  uid: fa4b2b55-fe16-4921-9c65-7b5eddc820ba
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>Then I created the following <code>hello-world-deploy.yml</code> deployment file.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world-deployment
  labels:
    app: hello-world-app
spec:
  selector:
    matchLabels:
      app: hello-world-app
  template:
    metadata:
      labels:
        app: hello-world-app
    spec:
      containers:
      - name: hello-world-app
        image: registry.hub.docker.com/repository/docker/projecthelloworld/helloworld-container:V1
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
        ports:
          - containerPort: 80

      imagePullSecrets:
      - name: regcred
</code></pre>
<p>Following the above, I created deployment but the pod is showing the status <code>ErrImagePull</code></p>
<p>On describing the pod, I can see that the secrets are mounted as expected.</p>
<pre><code>Name:         hello-world-deployment-b74c8c7db-26r2f
Namespace:    default
Priority:     0
Node:         ip-192-168-41-226.eu-west-2.compute.internal/192.168.41.226
Start Time:   Tue, 03 Aug 2021 13:53:17 +0100
Labels:       app=hello-world-app
              pod-template-hash=b74c8c7db
Annotations:  kubernetes.io/psp: eks.privileged
Status:       Pending
IP:           192.168.51.2
IPs:
  IP:           192.168.51.2
Controlled By:  ReplicaSet/hello-world-deployment-b74c8c7db
Containers:
  hello-world-app:
    Container ID:
    Image:          registry.hub.docker.com/repository/docker/projecthelloworld/helloworld-container:hello-world-service.V.0
    Image ID:
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:     500m
      memory:  128Mi
    Requests:
      cpu:        500m
      memory:     128Mi
    Environment:  &lt;none&gt;
Mounts:
  /var/run/secrets/kubernetes.io/serviceaccount from default-token-h8j4t (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-h8j4t:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-h8j4t
    Optional:    false
</code></pre>
<p>I am not sure, in which step I am going wrong. Any help would greatly appreciated.</p>
<p><strong>Update</strong>: I login to docker and tried to pull the image from command prompt</p>
<pre><code>docker pull registry.hub.docker.com/repository/docker/projecthelloworld/helloworld-container:V1
</code></pre>
<p>and got the same response</p>
<pre><code>Error response from daemon: unauthorized: authentication required
</code></pre>
<p>Output from the json.config file</p>
<pre><code>{
        &quot;auths&quot;: {
                &quot;registry.hub.docker.com&quot;: {}
        },
        &quot;credsStore&quot;: &quot;desktop&quot;
}
</code></pre>

tintin
<p>Found the issue, the deployment file's image property had a dns name <code>hub.docker.com</code> along with the uri path <code>/repository/docker/</code></p>
<pre><code>image: registry.hub.docker.com/repository/docker/projecthelloworld/helloworld-container:V1
    
</code></pre>
<p>Removing it got it working, it should have been</p>
<pre><code>image: projecthelloworld/helloworld-container:V1
</code></pre>
