Docker
Kubernetes
Local Repository
Container Image
DevOps

Pulling local repository docker image from kubernetes

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Kubernetes cannot pull an image from "your local Docker repository" unless the cluster nodes can actually reach that image source. That is the core misunderstanding behind many local-image deployment problems. The solution depends on whether the image is already loaded into the node runtime, hosted in a reachable registry, or sitting only on your laptop's Docker daemon.

Understand What Kubernetes Actually Pulls From

When a Pod starts, the kubelet on a node asks the container runtime for the image. That means the node, not your terminal session, must have access to the image.

There are three common development cases:

  • the image is already loaded into the node's container runtime
  • the image lives in a registry that the nodes can reach
  • the image exists only in your local Docker daemon

Only the first two are directly usable by Kubernetes.

Case 1: The Image Is Already on the Node

If you are using a single-node local cluster or you manually loaded the image into the cluster runtime, tell Kubernetes not to pull it again:

yaml
1apiVersion: v1
2kind: Pod
3metadata:
4  name: demo
5spec:
6  containers:
7    - name: demo
8      image: my-app:dev
9      imagePullPolicy: Never

imagePullPolicy: Never tells Kubernetes to use the existing local image and fail if it is missing. IfNotPresent is slightly softer. It uses the local image if available and pulls only if it is absent.

This works well for local clusters where you have explicitly loaded the image onto the node.

Case 2: Use a Reachable Local Registry

For multi-node development or repeatable workflows, a local registry is usually the better answer. Run a registry that your Kubernetes nodes can reach, tag the image with that registry address, and push it there.

Example registry setup:

bash
docker run -d -p 5000:5000 --name registry registry:2
docker tag my-app:dev localhost:5000/my-app:dev
docker push localhost:5000/my-app:dev

Then reference that image in Kubernetes:

yaml
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4  name: my-app
5spec:
6  replicas: 1
7  selector:
8    matchLabels:
9      app: my-app
10  template:
11    metadata:
12      labels:
13        app: my-app
14    spec:
15      containers:
16        - name: my-app
17          image: localhost:5000/my-app:dev
18          imagePullPolicy: IfNotPresent

The important detail is that localhost must mean something useful from the node's point of view. In many cluster setups, localhost:5000 from inside the node is not the same machine as your laptop shell. That is why cluster-specific docs for kind, minikube, or k3d often include a special registry hostname or image-loading command.

Case 3: The Image Exists Only on Your Laptop

If the image is only present in your local Docker daemon and the cluster nodes use a different container runtime or different Docker daemon, Kubernetes cannot see it. In that situation, you must either:

  • push the image to a registry the nodes can reach
  • load the image into the cluster's node runtime
  • rebuild the image inside the runtime the cluster actually uses

There is no generic Kubernetes feature that pulls directly from your workstation's private image cache.

Diagnose Image Pull Failures Properly

When Pods fail with ImagePullBackOff or ErrImagePull, inspect the events first:

bash
kubectl describe pod demo
kubectl get events --sort-by=.metadata.creationTimestamp

Those messages usually tell you whether the problem is:

  • registry unreachable
  • image name or tag wrong
  • authentication missing
  • image not present locally when Never was used

That is much faster than changing YAML blindly.

Common Pitfalls

  • Assuming Kubernetes can see images that exist only in your laptop's Docker daemon.
  • Using imagePullPolicy: Never before the image is actually loaded onto the node.
  • Pointing at localhost:5000 when the node's localhost is not your local machine.
  • Treating a local registry and a local Docker cache as the same thing.
  • Debugging the application container when the real issue is image distribution.

Summary

  • Kubernetes pulls images from the node's perspective, not from your terminal's perspective.
  • Use Never or IfNotPresent only when the image is already on the node runtime.
  • A reachable local registry is the cleanest repeatable workflow for development clusters.
  • If the image exists only on your laptop, Kubernetes cannot use it until you push or load it.
  • Read Pod events first when diagnosing pull failures.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.