title: Use local docker image with minikube
body: <p>I was following this URL: <a href="https://stackoverflow.com/questions/42564058/how-to-use-local-docker-images-with-minikube">How to use local docker images with Minikube?</a>
  I couldn't add a comment, so thought of putting my question here:</p>
  
  <p>On my laptop, I have Linux Mint OS. Details as below:</p>
  
  <pre><code>Mint version 19, 
  Code name : Tara,
  PackageBase : Ubuntu Bionic
  Cinnamon (64-bit)
  </code></pre>
  
  <p>As per one the answer on the above-referenced link:</p>
  
  <ol>
  <li>I started minikube and checked pods and deployments</li>
  </ol>
  
  <blockquote>
  <pre><code>xxxxxxxxx:~$ pwd
  /home/sj
  
  xxxxxxxxxx:~$ minikube start
  xxxxxxxxxx:~$ kubectl get pods
  xxxxxxxxxx:~$ kubectl get deployments
  </code></pre>
  </blockquote>
  
  <p>I ran command docker images</p>
  
  <pre><code>xxxxxxxxx:~$ docker images
  
  REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE
  &lt;username&gt;/spring-docker-01   latest              e10f88e1308d        6 days ago          640MB
  openjdk                           8                   81f83aac57d6        4 weeks ago         624MB
  mysql                             5.7                 563a026a1511        4 weeks ago         372MB
  </code></pre>
  
  <ol start="2">
  <li>I ran below command:     </li>
  </ol>
  
  <blockquote>
    <p>eval $(minikube docker-env)</p>
  </blockquote>
  
  <ol start="3">
  <li><p>Now when I check docker images, looks like as the <a href="https://github.com/kubernetes/minikube/blob/0c616a6b42b28a1aab8397f5a9061f8ebbd9f3d9/README.md#reusing-the-docker-daemon" rel="nofollow noreferrer">README</a> describes, it reuses the Docker daemon from Minikube with eval $(minikube docker-env).</p>
  
  <p>xxxxxxxxxxxxx:~$ docker images</p></li>
  </ol>
  
  <blockquote>
  <pre><code>REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
  nginx                                      alpine              33c5c6e11024        9 days ago          17.7MB
  k8s.gcr.io/coredns                         1.2.2               367cdc8433a4        5 weeks ago         39.2MB
  k8s.gcr.io/kubernetes-dashboard-amd64      v1.10.0             0dab2435c100        5 weeks ago         122MB
  k8s.gcr.io/kube-proxy-amd64                v1.10.0             bfc21aadc7d3        6 months ago        97MB
  k8s.gcr.io/kube-controller-manager-amd64   v1.10.0             ad86dbed1555        6 months ago        148MB
  k8s.gcr.io/kube-apiserver-amd64            v1.10.0             af20925d51a3        6 months ago        225MB
  k8s.gcr.io/kube-scheduler-amd64            v1.10.0             704ba848e69a        6 months ago        50.4MB
  k8s.gcr.io/etcd-amd64                      3.1.12              52920ad46f5b        6 months ago        193MB
  k8s.gcr.io/kube-addon-manager              v8.6                9c16409588eb        7 months ago        78.4MB
  k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64     1.14.8              c2ce1ffb51ed        9 months ago        41MB
  k8s.gcr.io/k8s-dns-sidecar-amd64           1.14.8              6f7f2dc7fab5        9 months ago        42.2MB
  k8s.gcr.io/k8s-dns-kube-dns-amd64          1.14.8              80cc5ea4b547        9 months ago        50.5MB
  k8s.gcr.io/pause-amd64                     3.1                 da86e6ba6ca1        9 months ago        742kB
  gcr.io/k8s-minikube/storage-provisioner    v1.8.1              4689081edb10        11 months ago       80.8MB
  k8s.gcr.io/echoserver                      1.4                 a90209bb39e3        2 years ago         140MB
  </code></pre>
  </blockquote>
  
  <p><em>Note: if noticed docker images command pulled different images before and after step 2.</em></p>
  
  <ol start="4">
  <li>As I didn't see the image that I wanted to put on minikube, I pulled it from my docker hub.</li>
  </ol>
  
  <blockquote>
  <pre><code>xxxxxxxxxxxxx:~$ docker pull &lt;username&gt;/spring-docker-01
  Using default tag: latest
  latest: Pulling from &lt;username&gt;/spring-docker-01
  05d1a5232b46: Pull complete 
  5cee356eda6b: Pull complete 
  89d3385f0fd3: Pull complete 
  80ae6b477848: Pull complete 
  40624ba8b77e: Pull complete 
  8081dc39373d: Pull complete 
  8a4b3841871b: Pull complete 
  b919b8fd1620: Pull complete 
  2760538fe600: Pull complete 
  48e4bd518143: Pull complete 
  Digest: sha256:277e8f7cfffdfe782df86eb0cd0663823efc3f17bb5d4c164a149e6a59865e11
  Status: Downloaded newer image for &lt;username&gt;/spring-docker-01:latest
  </code></pre>
  </blockquote>
  
  <ol start="5">
  <li>Verified if I can see that image using "docker images" command.</li>
  </ol>
  
  <blockquote>
  <pre><code>xxxxxxxxxxxxx:~$ docker images
  REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
  &lt;username&gt;/spring-docker-01            latest              e10f88e1308d        6 days ago          640MB
  nginx                                      alpine              33c5c6e11024        10 days ago         17.7MB
  </code></pre>
  </blockquote>
  
  <ol start="6">
  <li>Then I tried to build image as stated in referenced link step.</li>
  </ol>
  
  <blockquote>
  <pre><code>xxxxxxxxxx:~$ docker build -t &lt;username&gt;/spring-docker-01 .
  unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/sj/Dockerfile: no such file or directory
  </code></pre>
  </blockquote>
  
  <p><strong>As the error states that dockerfile doesn't exist at the location, I am not sure where exactly I can see dockerfile for the image I had pulled from docker hub.</strong></p>
  
  <p>Looks like I have to go to the location where the image has been pulled and from that location, I need to run the above-mentioned command. Please correct me wrong.</p>
  
  <p>Below are the steps, I will be doing after I fix the above-mentioned issue.</p>
  
  <pre><code># Run in minikube
  kubectl run hello-foo --image=myImage --image-pull-policy=Never
  
  # Check that it's running
  kubectl get pods
  </code></pre>
  
  <hr>
  
  <p>UPDATE-1</p>
  
  <p>There is mistake in above steps.
  Step 6 is not needed. Image has already been pulled from docker hub, so no need of <code>docker build</code> command.</p>
  
  <p>With that, I went ahead and followed instructions as mentioned by @aurelius in response.</p>
  
  <pre><code>xxxxxxxxx:~$ kubectl run sdk-02 --image=&lt;username&gt;/spring-docker-01:latest --image-pull-policy=Never
  kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
  deployment.apps/sdk-02 created
  </code></pre>
  
  <p>Checked pods and deployments</p>
  
  <pre><code>xxxxxxxxx:~$ kubectl get pods
  NAME                         READY   STATUS    RESTARTS   AGE
  sdk-02-b6db97984-2znlt       1/1     Running   0          27s
  xxxxxxxxx:~$ kubectl get deployments
  NAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
  sdk-02      1         1         1            1           35s
  </code></pre>
  
  <p>Then exposed deployment on port 8084 as I was using other ports like 8080 thru 8083</p>
  
  <pre><code>xxxxxxxxx:~$ kubectl expose deployment sdk-02 --type=NodePort --port=8084
  service/sdk-02 exposed
  </code></pre>
  
  <p>Then verified if service has been started, checked if no issue on kubernetes dashboard and then checked the url</p>
  
  <pre><code>xxxxxxxxx:~$ kubectl get services
  NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
  kubernetes   ClusterIP      10.96.0.1        &lt;none&gt;        443/TCP          7h
  sdk-02       NodePort       10.100.125.120   &lt;none&gt;        8084:30362/TCP   13s
  
  xxxxxxxxx:~$ minikube service sdk-02 --url
  http://192.168.99.101:30362
  </code></pre>
  
  <p>When I tried to open URL: <a href="http://192.168.99.101:30362" rel="nofollow noreferrer">http://192.168.99.101:30362</a> in browser I got message:</p>
  
  <pre><code>This site can’t be reached
  192.168.99.101 refused to connect.
  Search Google for 192 168 101 30362
  ERR_CONNECTION_REFUSED
  </code></pre>
  
  <p><strong>So the question : Is there any issue with steps performed?</strong></p>
  
  <hr>
  
  <p>UPDATE-2</p>
  
  <p>The issue was with below step:</p>
  
  <pre><code>xxxxxxxxx:~$ kubectl expose deployment sdk-02 --type=NodePort --port=8084
      service/sdk-02 exposed
  </code></pre>
  
  <p>Upon checking Dockerfile of my image : <code>&lt;username&gt;/spring-docker-01:latest</code> I was exposing it to 8083 something like <code>EXPOSE 8083</code>
  May be that was causing issue. 
  So I went ahead and changed expose command:</p>
  
  <pre><code>xxxxxxxxx:~$ kubectl expose deployment sdk-02 --type=NodePort --port=8083
  service/sdk-02 exposed
  </code></pre>
  
  <p>And then it started working.</p>
  
  <p><em>If anyone has something to add to this, please feel free.</em></p>
  
  <p><strong>However I am still not sure where exactly I can see dockerfile for the image I had pulled from docker hub.</strong></p>