<p>In my <code>Azure DevOps</code> I added a <code>Docker Registry Service Connection</code> via the "Other" option (username and password).</p>

<p>This service connection works in my <code>CI Pipeline</code> when push images via <code>docker compose</code>.</p>

<p>But in my <code>CD Pipeline</code> (Release) pipeline, when I add the <code>Docker Registry Service Connection</code> in the Secrets section of my <code>Deploy to Kubernetes Task</code>.</p>

<p>In <code>Azure DevOps</code> the <code>Deploy to Kubernetes Task</code> was processed successfully. But in the cluster the pods for the images from my <code>Azure Container Registry</code> show following error:</p>

<blockquote>
  <p>Failed to pull image "xxx.azurecr.io/service.api:latest": [rpc error:
  code = Unknown desc = Error response from daemon: Get
  <a href="https://xxx.azurecr.io/v2/service.api/manifests/latest" rel="nofollow noreferrer">https://xxx.azurecr.io/v2/service.api/manifests/latest</a>: unauthorized:
  authentication required, rpc error: code = Unknown desc = Error
  response from daemon: Get
  <a href="https://xxx.azurecr.io/v2/service.api/manifests/latest" rel="nofollow noreferrer">https://xxx.azurecr.io/v2/service.api/manifests/latest</a>: unauthorized:
  authentication required]</p>
</blockquote>

<p>How do I fix this error?</p>

<p>you need to configure kubernetes with access to private registry (the fact that you configured Azure Devops to do that doesn't matter, it doesnt 'push' images to kubernetes, it just issues commands). You can follow <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">this link</a> to do that.</p>

<p>In short you need to do this:</p>

<pre><code>kubectl create secret docker-registry regcred --docker-server=&lt;your-registry-server&gt; --docker-username=&lt;your-name&gt; --docker-password=&lt;your-pword&gt; --docker-email=&lt;your-email&gt;
</code></pre>

<p>and then add ImagePullSecrets to your pod definition:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: &lt;your-private-image&gt;
  imagePullSecrets:
  - name: regcred
</code></pre>
