<p>I'm using minikube on a Fedora based machine to run a simple mongo-db deployment on my local machine but I'm constantly getting <code>ImagePullBackOff</code> error. Here is the yaml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb-deployment
  labels:
    app: mongodb
spec:
 replicas: 1
 selector:
   matchLabels:
     app: mongodb
 template: 
  metadata:
    labels:
      app: mongodb
  spec:
    containers:
      - name: mongodb
        image: mongo
        ports:
            - containerPort: 27017
        env:
           - name: MONGO_INITDB_ROOT_USERNAME
             valueFrom:
              secretKeyRef:
                 name: mongodb-secret
                 key: mongo-root-username
           - name: MONGO_INITDB_ROOT_PASSWORD
             valueFrom:
              secretKeyRef:
                 name: mongodb-secret
                 key: mongo-root-password
 
 
apiVersion: v1
kind: Service
metadata:
   name: mongodb-service
spec:
  selector:
      app: mongodb
  ports:
     - protocol: TCP
       port: 27017
       targetPort: 27017
</code></pre>
<p>I tried to pull the image locally by using <code>docker pull mongo</code>, <code>minikube image pull mongo</code> &amp; <code>minikube image pull mongo-express</code> several times while restarting docker and minikube several times.</p>
<p>Logining into dockerhub (both in broweser and through terminal didn't work)</p>
<p>I also tried to login into docker using <code>docker login</code> command and then modified my <code>/etc/resolv.conf</code> and adding <code>nameserver 8.8.8.8</code> and then restartied docker using <code>sudo systemctl restart docker</code> but even that failed to work.</p>
<p>On running <code>kubectl describe pod</code> command I get this output:</p>
<pre><code>Name:         mongodb-deployment-6bf8f4c466-85b2h
Namespace:    default
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Mon, 29 Aug 2022 23:04:12 +0530
Labels:       app=mongodb
          pod-template-hash=6bf8f4c466
Annotations:  &lt;none&gt;
Status:       Pending
IP:           172.17.0.2
IPs:
  IP:           172.17.0.2
Controlled By:  ReplicaSet/mongodb-deployment-6bf8f4c466
Containers:
 mongodb:
   Container ID:   
   Image:          mongo
   Image ID:       
   Port:           27017/TCP
   Host Port:      0/TCP
   State:          Waiting
     Reason:       ImagePullBackOff
   Ready:          False
   Restart Count:  0
   Environment:
     MONGO_INITDB_ROOT_USERNAME:  &lt;set to the key 'mongo-root-username' in secret 'mongodb-secret'&gt;  
     Optional: false
     MONGO_INITDB_ROOT_PASSWORD:  &lt;set to the key 'mongo-root-password' in secret 'mongodb-secret'&gt;  
     Optional: false
   Mounts:
      
     /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-vlcxl (ro)
  Conditions:
       Type              Status
       Initialized       True 
       Ready             False 
       ContainersReady   False 
       PodScheduled      True 
  Volumes:
     kube-api-access-vlcxl:
     Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                         node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason          Age                  From               Message
</code></pre>
<hr />
<pre><code>  Normal   Scheduled       22m                  default-scheduler  Successfully assigned default/mongodb-deployment-6bf8f4c466-85b2h to minikube
  Warning  Failed          18m (x2 over 20m)    kubelet            Failed to pull image &quot;mongo:latest&quot;: rpc error: code = Unknown desc = context deadline exceeded
  Warning  Failed          18m (x2 over 20m)    kubelet            Error: ErrImagePull
  Normal   BackOff         17m (x2 over 20m)    kubelet            Back-off pulling image &quot;mongo:latest&quot;
  Warning  Failed          17m (x2 over 20m)    kubelet            Error: ImagePullBackOff
  Normal   Pulling         17m (x3 over 22m)    kubelet            Pulling image &quot;mongo:latest&quot;
  Normal   SandboxChanged  11m                  kubelet            Pod sandbox changed, it will be killed and re-created.
  Normal   Pulling         3m59s (x4 over 11m)  kubelet            Pulling image &quot;mongo:latest&quot;
  Warning  Failed          2m (x4 over 9m16s)   kubelet            Failed to pull image &quot;mongo:latest&quot;: rpc error: code = Unknown desc = context deadline exceeded
  Warning  Failed          2m (x4 over 9m16s)   kubelet            Error: ErrImagePull
  Normal   BackOff         83s (x7 over 9m15s)  kubelet            Back-off pulling image &quot;mongo:latest&quot;
  Warning  Failed          83s (x7 over 9m15s)  kubelet            Error: ImagePullBackOff
</code></pre>
<p>PS: Ignore any any spacing errors</p>

<p>I think your internet connection is slow. The timeout to pull an image is <code>120</code> seconds, so kubectl could not pull the image in under <code>120</code> seconds.</p>
<p>First, pull the image via <code>Docker</code></p>
<pre class="lang-bash prettyprint-override"><code>docker image pull mongo
</code></pre>
<p>Then load the downloaded image to <code>minikube</code></p>
<pre class="lang-bash prettyprint-override"><code>minikube image load mongo
</code></pre>
<p>And then everything will work because now kubectl will use the image that is stored locally.</p>
