<p>I'm struggling to get Kubernetes to work with my private hub.docker.com registry image.</p>

<p>I am using kubectl version: <code>Client Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.0.1588+e44c8e6661c931", GitCommit:"e44c8e6661c931f7fd434911b0d3bca140e1df3a", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"1", GitVersion:"v1.1.3", GitCommit:"6a81b50c7e97bbe0ade075de55ab4fa34f049dc2", GitTreeState:"clean"}</code></p>

<p>and Vagrant <code>1.7.4</code> on Mac OS X <code>Yosemite 10.10.5</code></p>

<p>I followed the instructions given here: <a href="https://github.com/kubernetes/kubernetes/blob/release-1.1/docs/user-guide/images.md#pre-pulling-images" rel="noreferrer">https://github.com/kubernetes/kubernetes/blob/release-1.1/docs/user-guide/images.md#pre-pulling-images</a></p>

<p>In a nutshell, it says you should login to the registry then base64 encode the contents of the resulting <code>.docker/config.json</code>, and use that in a yaml document as follows:</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: myregistrykey
data:
  .dockercfg: eyAiYXV0aHMiOiB7ICJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOiB7ICJhdXRoIjogImFXNTBjbWx1YzJsak9tSTJVVTR5Z...h1YkBpbnRyaW5zaWMud29ybGQiIH0gfSB9Cg==
type: kubernetes.io/dockercfg
</code></pre>

<p>Then feed that to kubectl. I then used the resulting key (here called <code>myregistrykey</code>) in my pod definition:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: authorities-backend
spec:
  containers:
    - name: authorities-backend
      image: intrinsic/authorities-backend:latest
  imagePullSecrets:
    - name: myregistrykey
</code></pre>

<p>and <code>kubectl create</code>d it.</p>

<p>However, kubectl keeps failing to retrieve the image:</p>

<pre><code>[root@kubernetes-master intrinsic]# kubectl get pods
NAME                  READY     STATUS           RESTARTS   AGE
authorities-backend   0/1       PullImageError   0          7m
</code></pre>

<p>docker pull on the Kubernetes master worked however.</p>

<p>What am I missing?</p>

<h1>UPDATE</h1>

<p><b>In the pod definition above, I had omitted to specify the registry host, i.e. docker.io. Fixing it, it becomes:
<code>image: docker.io/intrinsic/authorities-backend:latest</code>
However, the problem persists. Doing <code>kubectl get events -w</code> gets me:
<code>
6s          0s         2         authorities-backend   Pod       spec.containers{authorities-backend}   Failed    {kubelet 10.245.1.3}   Failed to pull image "docker.io/intrinsic/authorities-backend": image pull failed for docker.io/intrinsic/authorities-backend, this may be because there are no credentials on this request.  details: (Error: image intrinsic/authorities-backend:latest not found)
</code>
I know the secret has been properly registered, as I have it under <code>kubectl get secrets</code>:
<code>
NAME                  TYPE                                  DATA      AGE
default-token-a7s5n   kubernetes.io/service-account-token   2         51m
myregistrykey         kubernetes.io/dockercfg               1         50m
</code></p>

<p>Still confused...</p>

<p></b></p>

<p>Candide</p>

<p>So, I kept researching the web for an answer to my problem and eventually found this:</p>

<p><a href="https://github.com/kubernetes/kubernetes/issues/7954#issuecomment-115241561" rel="nofollow">https://github.com/kubernetes/kubernetes/issues/7954#issuecomment-115241561</a></p>

<p>At the very end of the thread, jjw27 has nailed it. The <a href="https://github.com/kubernetes/kubernetes/blob/release-1.1/docs/user-guide/images.md#pre-pulling-images" rel="nofollow">kubernetes documentation</a> mentions the <code>.dockercfg.json</code> file just to say that its contents needs to be base64-encoded. There are actually two issues with this file:</p>

<ol>
<li>it looks like it morphed into another file actually, i.e. <code>.docker/config.json</code></li>
<li>the auth info in this file is wrapped by an additional <code>auths</code> objects, which you have to get rid of.</li>
</ol>

<p>Quoting jjw27</p>

<p>Did not work:</p>

<pre><code>{
  "auths": {
    "hub.example.com:1024": {
      "auth": "asdf=",
      "email": "example@example.com"
     }
  }
}
</code></pre>

<p>Worked:</p>

<pre><code>{
  "hub.example.com:1024": {
    "auth": "asdf=",
    "email": "example@example.com"
  }
}
</code></pre>

<p>Google, please update this doc!!</p>

<p>Message to Kubernetes devs #2: Also, not complaining with a malformed base64-encoded secret is very misleading. Please validate user input and complain if it contains errors.</p>
