<p>I'm starting in Kubernetes and I'm trying to update the Image in DockerHub that is used for the Kubernetes's Pod creation and then with <code>kubectl rollout restart deployment deploymentName</code> command it should pull the newest image and rebuild the pods.
The problem I'm facing is that it only works when I specify a version in the tag both in the image and the deployment.yaml` file.</p>
<p>In my repo I have 2 images <code>fixit-server:latest</code> and <code>fixit-server:0.0.2</code> (the actual latest one).</p>
<p>With <code>deployment.yaml</code> file set as</p>
<pre><code>spec:
      containers:
      - name: fixit-server-container
        image: vinnytwice/fixit-server
        # imagePullPolicy: Never
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
</code></pre>
<p>I run <code>kubectl apply -f infrastructure/k8s/server-deployment.yaml</code> and it gets created, but when running <code>kubectl get pods</code> I get</p>
<pre><code>vincenzocalia@vincenzos-MacBook-Air server-node % kubectl get pods
NAME                            READY   STATUS         RESTARTS   AGE
fixit-server-5c7bfbc5b7-cgk24   0/1     ErrImagePull   0          7s
fixit-server-5c7bfbc5b7-g7f8x   0/1     ErrImagePull   0          7s
</code></pre>
<p>I then instead specify the version number in the <code>deployment.yaml</code> file</p>
<pre><code> spec:
      containers:
      - name: fixit-server-container
        image: vinnytwice/fixit-server:0.0.2
        # imagePullPolicy: Never
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
</code></pre>
<p>run again <code>kubectl apply -f infrastructure/k8s/server-deployment.yaml</code> and get <code>configured</code> as expected.
Running <code>kubectl rollout restart deployment fixit-server</code> I get <code>restarted</code> as expected.
But still running <code>kubectl get pods</code> shows</p>
<pre><code>vincenzocalia@vincenzos-MacBook-Air server-node % kubectl get pods
NAME                            READY   STATUS             RESTARTS   AGE
fixit-server-5c7bfbc5b7-cgk24   0/1     ImagePullBackOff   0          12m
fixit-server-5d78f8848c-bbxzx   0/1     ImagePullBackOff   0          2m58s
fixit-server-66cb98855c-mg2jn   0/1     ImagePullBackOff   0          74s
</code></pre>
<p>So I deleted the deployment and applied it again and pods are now running correctly.</p>
<p>Why when omitting a version number for the image to use ( which should imply :latest) the <code>:latest</code> tagged image doesn't get pulled from the repo?
What's the correct way of using the <code>:latest</code> tagged image?
Thank you very much.
Cheers</p>
<p>repo:
<a href="https://i.stack.imgur.com/Cz4Xz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cz4Xz.png" alt="enter image description here" /></a></p>
<p>images:</p>
<pre><code>REPOSITORY                                                TAG                                                                          IMAGE ID       CREATED         SIZE
vinnytwice/fixit-server                                   0.0.2                                                                        53cac5b0a876   10 hours ago    1.3GB
vinnytwice/fixit-server                                   latest                                                                       53cac5b0a876   10 hours ago    1.3GB
</code></pre>

Vincenzo
<p>You can use <a href="https://github.com/ryandaniels/docker-script-find-latest-image-tag/blob/aed09da3813429cbe979e34a050a48c3b19a7002/docker_image_find_tag.sh" rel="nofollow noreferrer"><code>docker_image_find_tag.sh</code></a> to check if your image has a <code>latest</code> tag or not.<br />
It will show the tag/version for  shows <code>image:&lt;none&gt;</code> or <code>image:latest</code>.</p>
<p>That way, you can check if, that mentioned in &quot;<a href="https://komodor.com/learn/how-to-fix-errimagepull-and-imagepullbackoff/" rel="nofollow noreferrer">How to fix ErrImagePull and ImagePullBackoff</a>&quot; if this is linked to:</p>
<blockquote>
<ul>
<li><strong>Cause</strong>: Pod specification provides an invalid tag, or fails to provide a tag</li>
<li><strong>Resolution</strong>: Edit pod specification and provide the correct tag.<br />
If the image does not have a latest tag, you must provide a valid tag</li>
</ul>
</blockquote>
<p>And:</p>
<blockquote>
<p>What's the correct way of using the <code>:latest</code> tagged image</p>
</blockquote>
<p>Ideally, by <em>not</em> using it ;) <code>latest</code> can shift at any time, and by using a <em>fixed</em> label, you ensure a better reproducibility of your deployment.</p>
