<p>I created a Bitbucket pipeline and trying yo deploy a basic pod to Azure AKS.
bitbucket-pipelines.yml is below;</p>
<pre><code>image: atlassian/default-image:2

options:
  docker: true
pipelines:
  default:
    - step:
        name: Docker login
        caches:
           - docker
        script:
          - docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
    - step:
        name: &quot;Deploy to PROD&quot;
        deployment: production
        script:
          - pipe: microsoft/azure-aks-deploy:1.0.0
            variables:
              AZURE_APP_ID: $AZURE_APP_ID
              AZURE_PASSWORD: $AZURE_PASSWORD
              AZURE_TENANT_ID: $AZURE_TENANT_ID
              AZURE_AKS_NAME: &quot;demo-aks&quot;
              AZURE_RESOURCE_GROUP: &quot;demo-rg&quot;
              KUBECTL_COMMAND: 'apply'
              KUBERNETES_SPEC_FILE: 'test.yaml'
</code></pre>
<p>and test.yaml file is below;</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test
  labels:
    app: test
spec:
  containers:
  - name: test
    image: myrepository/test:1234
    command: [&quot;/bin/sleep&quot;, &quot;3650d&quot;]
    imagePullPolicy: IfNotPresent
  restartPolicy: Always
</code></pre>
<p>&quot;kubectl apply -f test-yaml&quot; command seems successfully executed and it's trying to create pod, but gives &quot;docker login&quot; error.</p>
<pre><code>  Warning  Failed     9s (x2 over 24s)   kubelet            Failed to pull image &quot;myrepository/test:1234&quot;: rpc error: code = Unknown desc = Error response from daemon: pull access denied for myrepository/test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
  Warning  Failed     9s (x2 over 24s)   kubelet            Error: ErrImagePul
</code></pre>
<p>Docker user and pass variables already added and they're correct. Not sure where is the problem.
Thanks!</p>

yatta
<p>Have you created the right Docker credentials in AKS?
If you are sure you docker login is right, then create the following secret in AKS:</p>
<pre><code>kubectl create secret generic regcred \
    --from-file=.dockerconfigjson=&lt;path/to/.docker/config.json&gt; \
    --type=kubernetes.io/dockerconfigjson
</code></pre>
<p>where <code>&lt;path/to/.docker/config.json&gt;</code> usually is ~/.docker/config.json (of course you need to be able to reach that repo from your machine).</p>
<p>Then, quote this secret credential in your pod definition:</p>
<pre><code>  imagePullSecrets:
  - name: regcred
</code></pre>
<p>To use your example:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test
  labels:
    app: test
spec:
  containers:
  - name: test
    image: myrepository/test:1234
    command: [&quot;/bin/sleep&quot;, &quot;3650d&quot;]
    imagePullPolicy: IfNotPresent
  imagePullSecrets:
  - name: regcred
  restartPolicy: Always
</code></pre>
<p>AKS can easily pull images from public Docker Hub repositories or from Azure ACR (Azure Container Registry), but to connect to Docker Hub private you need to give the right connection data.</p>
<p>Reference: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a></p>
