Kubernetes
Container Image
Machine Learning
Web Development
Software Engineering

Kubernetes "Container image already present on machine" explained

Codemia Knowledge Hub ·

The kubelet on the node found the required container image already stored locally, so it reused it instead of pulling it from the registry again. Whether Kubernetes reuses a local image or pulls a fresh one is controlled by the container's imagePullPolicy.

How the kubelet decides whether to pull

A container image is a standalone, executable package with everything needed to run the software: code, runtime, libraries, environment variables and configuration files. Kubernetes pulls images from a registry (such as Docker Hub, Google Container Registry or a private registry) and runs them on the cluster's nodes.

When a pod is scheduled, the kubelet (the agent on each node) checks whether the image is available locally. If it is there and matches the signature the pod's configuration requires, it is reused. That means faster pod startup and less bandwidth, which helps most where internet access is slow or expensive.

imagePullPolicy values

  • Always: always pull from the registry, even if the image is already on the node.
  • IfNotPresent: pull only if the image is not on the node.
  • Never: never pull; the pod fails to start if the image is not on the node.
yaml
1apiVersion: v1
2kind: Pod
3metadata:
4  name: example-pod
5spec:
6  containers:
7  - name: example-container
8    image: example/my-application:1.2.3
9    imagePullPolicy: IfNotPresent

With IfNotPresent, Kubernetes reuses example/my-application:1.2.3 if the node has it and pulls it from the registry otherwise.

Choosing a policy

  • Caching: nodes usually keep a local image cache. IfNotPresent uses it, cutting network traffic and speeding up deployments.
  • Development: Always makes sure the latest image, with recent code changes, is used.
  • Production: tagged versions with IfNotPresent, or specific digests with Always, keep deployments reliable and consistent.
FactorDescriptionAdvantagesRecommended imagePullPolicy
Development SpeedRapid iterationQuick testingAlways
Network EfficiencyMinimal bandwidthReduced costsIfNotPresent
Deployment ConsistencyReliable versionsStable environmentSpecific digest with Always
Local Resource UsageHigh availabilityFast deploymentsIfNotPresent

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

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

View the course
ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design