matak8s
matak8s

Reputation: 557

Docker Image and it's Kubernetes Pod differ

I modified the contents in my Docker-Image and ran it's Kubernetes Pod. However, the Kubernetes Pod had the contents of the old version of the Docker Image and not the Modified One.

How is it possible?

I am guessing that the K8s worker node is trying to fetch as many layers from the local as possible and only few from the docker-registry. How to solve this issue such that every time the K8s worker node pull all the layers of the docker image from the Registry only?

Upvotes: 2

Views: 154

Answers (2)

Kamol Hasan
Kamol Hasan

Reputation: 13456

Set imagePullPolicy to Always.

Sample:

apiVersion: v1
kind: Pod
metadata:
  name: demo
spec:
  containers:
    - name: image-name
      image: my-image:0.0.1
      imagePullPolicy: Always # <<--here

The default pull policy is IfNotPresent which causes the kubelet to skip pulling an image if it already exists. If you would like to always force a pull, set it to Always.

Reference

Upvotes: 3

Dashrath Mundkar
Dashrath Mundkar

Reputation: 9184

Use imagePullPolicy: Always in your deployment

This option comes in handy if you deploy your application too often (Typical use case is CI/CD).

and one more thing if you want your image should be build fresh without any cache from local use --no-cache command in docker build command.

docker build -t myimage/imagename . --no-cache 

Upvotes: 1

Related Questions