<p>Im trying to create a pod using my local docker image as follow.</p>

<p>1.First I run this command in terminal </p>

<pre><code>eval $(minikube docker-env)
</code></pre>

<p>2.I created a docker image as follow</p>

<pre><code>sudo docker image build -t my-first-image:3.0.0 .
</code></pre>

<p>3.I created the pod.yml as shown below and I run this command</p>

<pre><code>kubectl -f create pod.yml.
</code></pre>

<p>4.then i tried to run this command</p>

<pre><code>kubectl get pods
</code></pre>

<p>but it shows following error </p>

<pre><code>
NAME                             READY   STATUS             RESTARTS   AGE
multiplication-b47499db9-phpb7   0/1     ImagePullBackOff   0          23h
my-first-pod                     0/1     ErrImagePull       0          7s
</code></pre>

<p>5.i get the pods logs</p>

<pre><code>kubectl describe pod my-first-pod 
</code></pre>

<pre><code>
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  99s                default-scheduler  Successfully assigned default/my-first-pod to minikube
  Warning  Failed     41s (x3 over 94s)  kubelet, minikube  Failed to pull image "my-first-image:3.0.0": rpc error: code = Unknown desc = Error response from daemon: pull access denied for my-first-image, repository does not exist or may require 'docker login'
  Warning  Failed     41s (x3 over 94s)  kubelet, minikube  Error: ErrImagePull
  Normal   BackOff    12s (x4 over 93s)  kubelet, minikube  Back-off pulling image "my-first-image:3.0.0"
  Warning  Failed     12s (x4 over 93s)  kubelet, minikube  Error: ImagePullBackOff
  Normal   Pulling    0s (x4 over 98s)   kubelet, minikube  pulling image "my-first-image:3.0.0"

</code></pre>

<pre><code>Dockerfile

    FROM node:carbon
    WORKDIR /app
    COPY . .
    CMD [ "node", "index.js" ]

</code></pre>

<pre><code>pods.yml

    kind: Pod
    apiVersion: v1
    metadata:
     name: my-first-pod
    spec:
     containers:
     - name: my-first-container
       image: my-first-image:3.0.0

</code></pre>

<pre><code>index.js

    var http = require('http');
    var server = http.createServer(function(request, response) {
     response.statusCode = 200;
     response.setHeader('Content-Type', 'text/plain');
     response.end('Welcome to the Golden Guide to Kubernetes
    Application Development!');
    });
    server.listen(3000, function() {
     console.log('Server running on port 3000');
    });

</code></pre>

Niranga Sandaruwan
<h2>Reason</h2>
<p>This is because it can't download the docker image defined in your pod definition file. By default it downloads required images from <a href="https://hub.docker.com/" rel="noreferrer">DockerHub</a>.</p>
<h2>Way 1</h2>
<p>So after creating your <code>my-first-image:3.0.0</code> image you have to publish it at DockerHub. For that create an account at DockerHub and login from terminal using <a href="https://docs.docker.com/engine/reference/commandline/login/" rel="noreferrer">login</a> command</p>
<pre><code>sudo docker login
</code></pre>
<p>After successful login, rebuild your docker image with your DockerHub username in tag and push it to DockerHub (<a href="https://docs.docker.com/engine/reference/commandline/image_push/" rel="noreferrer">more details</a>)</p>
<pre><code>sudo docker image build -t YOUR_DOCKERHUB_USERNAME/my-first-image:3.0.0 .
sudo docker push YOUR_DOCKERHUB_USERNAME/my-first-image:3.0.0
</code></pre>
<p>Update your image in <code>pod.yml</code> as <code>YOUR_DOCKERHUB_USERNAME/my-first-image:3.0.0</code> and create your pods as before.</p>
<h2>Way 2</h2>
<p>You can instruct to find required docker image from your local machine instead of downloading from DockerHub. To do so you have to add <code>imagePullPolicy: Never</code> in your <code>pod.yml</code> file under specific container description. Below is an example of your <code>pod.yml</code> file to show where to define image pull policy</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
 name: my-first-pod
spec:
 containers:
 - name: my-first-container
   image: YOUR_DOCKERHUB_USERNAME/my-first-image:3.0.0
   imagePullPolicy: Never
</code></pre>
