kubectl get pods shows ErrImagePull

Reason

This is because it can’t download the docker image defined in your pod definition file. By default it downloads required images from DockerHub.

Way 1

So after creating your my-first-image:3.0.0 image you have to publish it at DockerHub. For that create an account at DockerHub and login from terminal using login command

sudo docker login

After successful login, rebuild your docker image with your DockerHub username in tag and push it to DockerHub (more details)

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

Update your image in pod.yml as YOUR_DOCKERHUB_USERNAME/my-first-image:3.0.0 and create your pods as before.

Way 2

You can instruct to find required docker image from your local machine instead of downloading from DockerHub. To do so you have to add imagePullPolicy: Never in your pod.yml file under specific container description. Below is an example of your pod.yml file to show where to define image pull policy

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

Leave a Comment