<p>I am failing to pull from my private Docker Hub repository into my local Kubernetes setup running on Vagrant:</p>

<blockquote>
  <p>Container "hellonode" in pod "hellonode-n1hox" is waiting to start: image can't be
  pulled</p>
  
  <p>Failed to pull image "username/hellonode": Error: image username/hellonode:latest not found</p>
</blockquote>

<p>I have set up Kubernetes locally via Vagrant as described <a href="http://kubernetes.io/docs/getting-started-guides/vagrant/" rel="noreferrer">here</a> and created a secret named "dockerhub" with <em>kubectl create secret docker-registry dockerhub --docker-server=<a href="https://registry.hub.docker.com/" rel="noreferrer">https://registry.hub.docker.com/</a> --docker-username=username --docker-password=... --docker-email=...</em> which I supplied as the image pull secret.</p>

<p>I am running Kubernetes 1.2.0.</p>

<p>To pull a private DockerHub hosted image from a Kubernetes YAML:</p>

<p>Run these commands:</p>

<pre><code>DOCKER_REGISTRY_SERVER=docker.io
DOCKER_USER=Type your dockerhub username, same as when you `docker login`
DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`

kubectl create secret docker-registry myregistrykey \
  --docker-server=$DOCKER_REGISTRY_SERVER \
  --docker-username=$DOCKER_USER \
  --docker-password=$DOCKER_PASSWORD \
  --docker-email=$DOCKER_EMAIL
</code></pre>

<p>If your username on DockerHub is <code>DOCKER_USER</code>, and your private repo is called <code>PRIVATE_REPO_NAME</code>, and the image you want to pull is tagged as <code>latest</code>, create this <code>example.yaml</code> file:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: whatever
spec:
  containers:
    - name: whatever
      image: DOCKER_USER/PRIVATE_REPO_NAME:latest
      imagePullPolicy: Always
      command: [ "echo", "SUCCESS" ]
  imagePullSecrets:
    - name: myregistrykey
</code></pre>

<p>Then run:</p>

<pre><code>kubectl create -f example.yaml
</code></pre>
