<p>I'm trying to run kubernetes using minikube. I have some docker images in n azure container registry.</p>

<p>I created a secret like this:</p>

<pre><code>kubectl create secret docker-registry private-repo-secret --docker-server=myregistry.azurecr.io --docker-username=myusername --docker-password=mypassword --docker-email=myemail@mydomain.com
</code></pre>

<p>And I can see it's there:</p>

<pre><code>$ kubectl get secret         
NAME                  TYPE                                  DATA      AGE
default-token-x5xxh   kubernetes.io/service-account-token   3         17m
private-repo-secret   kubernetes.io/dockercfg               1         4m
</code></pre>

<p>And in my pods:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: frontend
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
      - name: frontend
        image: myregistry.azurecr.io/myproject/frontend:0.0.5
      imagePullSecrets:
        - name: private-repo-secret
</code></pre>

<p>Then why I get an <code>ErrImagePull</code> saying that the authentication is required?</p>

<p>EDIT:
Those credentials are correct and they work locally.
I've used one of the 2 pasword obtained with <code>az acr credential show -n myregistry</code>. The only difference is that in my local json I just have the auth property, not username, password and email.</p>

<p>If I describe one of my pods I get:</p>

<pre><code>  Warning  Failed                 5m (x4 over 6m)   kubelet, ip-172-20-49-180.eu-central-1.compute.internal  Failed to pull image "myregistry.azurecr.io/myproject/frontend:0.0.5": rpc error: code = Unknown desc = Error response from daemon: Get https://myregistry.azurecr.io/v2/myproject/frontend/manifests/0.0.5: unauthorized: authentication required
  Normal   BackOff                5m (x6 over 6m)   kubelet, ip-172-20-49-180.eu-central-1.compute.internal  Back-off pulling image "myregistry.azurecr.io/myproject/frontend:0.0.5"
  Warning  FailedSync             1m (x25 over 6m)  kubelet, ip-172-20-49-180.eu-central-1.compute.internal  Error syncing pod
</code></pre>

<p>kubectl version:</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.6", GitCommit:"6260bb08c46c31eea6cb538b34a9ceb3e406689c", GitTreeState:"clean", BuildDate:"2017-12-21T06:23:29Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>First, use following command to login into your docker registry.</p>

<pre><code>$ docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER --password=DOCKER_PASSWORD --email=DOCKER_EMAIL'.
</code></pre>

<p>This will generate a config file.</p>

<pre><code>$ ls -la ~/.docker/config.json
/home/shahriar/.docker/config.json
</code></pre>

<p>Now, use this this command to create secret.</p>

<pre><code>kubectl create secret generic my-secret-name --type=kubernetes.io/dockerconfigjson --from-file .dockerconfigjson=/home/shahriar/.docker/config.json
</code></pre>

<p>Your Secret will look like this</p>

<pre><code>apiVersion: v1
data:
  .dockerconfigjson: ewoJImF1dGh...l9Cn0=
kind: Secret
metadata:
  creationTimestamp: 2018-02-17T10:06:56Z
  name: my-secret-name
  namespace: default
  resourceVersion: "269"
  selfLink: /api/v1/namespaces/default/secrets/my-secret-name
  uid: 48f9f398-13ca-11e8-89c4-0800276cd577
type: kubernetes.io/dockerconfigjson
</code></pre>

<p>And the <code>.dockerconfigjson</code> will look like this</p>

<pre><code>{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "YWVyb2tp..XRlMDMzIw=="
        }
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/17.11.0-ce (linux)"
    }
}
</code></pre>
