<p>I have built some docker images and pushed them to my dockerhub repo. That means that these docker images are also available on my local computer. Here is an example of a public docker image in my repo <a href="https://hub.docker.com/repository/docker/vikash112/pathology/general" rel="nofollow noreferrer">https://hub.docker.com/repository/docker/vikash112/pathology/general</a></p>
<p>I wrote a yaml file for a pod that uses this image and I keep getting the following error</p>
<pre><code>  Type     Reason     Age                  From               Message
  ----     ------     ----                 ----               -------
  Normal   Scheduled  7m39s                default-scheduler  Successfully assigned default/classification-pod to digi1036734
  Warning  Failed     30s                  kubelet            Failed to pull image &quot;vikash112/pathology:0.1.0&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;docker.io/vikash112/pathology:0.1.0&quot;: failed to copy: httpReadSeeker: failed open: server message: invalid_token: authorization failed
  Warning  Failed     30s                  kubelet            Error: ErrImagePull
  Normal   BackOff    30s                  kubelet            Back-off pulling image &quot;vikash112/pathology:0.1.0&quot;
  Warning  Failed     30s                  kubelet            Error: ImagePullBackOff
  Normal   Pulling    16s (x2 over 7m38s)  kubelet            Pulling image &quot;vikash112/pathology:0.1.0&quot;
</code></pre>
<p>Now, the interesting thing is that</p>
<p>Because the image is available locally, k8s should not try to download the image
So, inorder to force k8s to not download the image, I used the imagePullPolicy: Never and I get the following error, even though the image is clearly present as shown</p>
<pre><code>Events:
  Type     Reason             Age               From               Message
  ----     ------             ----              ----               -------
  Normal   Scheduled          83s               default-scheduler  Successfully assigned default/classification-pod to digi1036734
  Warning  ErrImageNeverPull  5s (x9 over 82s)  kubelet            Container image &quot;vikash112/kftools:0.0.1&quot; is not present with pull policy of Never
  Warning  Failed             5s (x9 over 82s)  kubelet            Error: ErrImageNeverPull
(base) gupta@DIGI1036734:~/disk/Tools/kfp_pipeline_7/app/CAII/cai2package$ docker images | grep kftools 
vikash112/kftools                                        0.0.2             90e48f4cee7b   4 months ago    13.4GB
vikash112/kftools                                        0.0.1             1f00fe6b3e82   4 months ago    13.4GB

</code></pre>
<p>So, another thing I tried was to create a secret in k8s for my docker login following the instructions here <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a></p>
<p>However, I am able to pull the public repositories like mongodb, busybox etc. So, I don't know why my own public repositories have any problems while pulling.</p>
<p>How can we reproduce it (as minimally and precisely as possible)?
You can try it using the following yaml script</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: classification-pod
spec:
  restartPolicy: OnFailure
  containers:
    - name: caiiapp
      image: vikash112/hellok8s:v1
      imagePullPolicy: IfNotPresent
      resources:
        limits:
          nvidia.com/gpu: 1
  nodeSelector:
    kubernetes.io/hostname: digi1036734
</code></pre>
<p>Lets say you save the file as myscript.yaml. You can execute it as</p>
<pre><code>kubectl apply -f myscript.yaml
</code></pre>
<p>I dont expect k8s to pull any images if they are available locally. If it is trying to pull it should pull my images from docker hub as it is pulling other images like mongodb, busybox etc.</p>

screamingmamba
<blockquote>
<p>Because the image is available locally, k8s should not try to download the image</p>
</blockquote>
<p>Docker and Kubernetes do not share the same image store (with one small exception of Docker Desktop running Kubernetes from there). Therefore you need to push the images to a registry and pull them from there.</p>
<p>The image you have listed is 68 layers totaling over 7GB compressed. I would suggest trying to cut this way down to reduce the network and disk load on your system.</p>
<blockquote>
<p>invalid_token: authorization failed</p>
</blockquote>
<p>This error indicates that any authentication credentials you have provided are not correct. Double check that the credentials you have entered into kubernetes show the correct base64 encoded user/password (docker desktop does not place credentials in the config file by default). If you have 2fa enabled in Docker Hub, make sure you are using an access token rather than your password.</p>
