Why We Build Images Again and Again

Every time you make a code change, you need to build a new Docker image and push it. Kubernetes does not pull from your local machine — it always pulls from Docker Hub.

So the cycle for every change is:

Make code change → build new image → push to Docker Hub → update Kubernetes

Each new version gets a new tag so you can track and go back to any version:

daksh12398/testingapp:01   # version 1
daksh12398/testingapp:02   # version 2 after changes
daksh12398/testingapp:03   # version 3 after more changes

Full Flow — First Time Setup

# Build your image
docker build -t daksh12398/testingapp:01 .

# Login to Docker Hub
docker login

# Push image to Docker Hub
docker push daksh12398/testingapp:01

# Create Kubernetes deployment
# deployment ki commands m hamesha deployment k baad naam ayega jo create kiya h jese set images m dekho niche
kubectl create deployment my-webapp --image=daksh12398/testingapp:01

Full Flow — Every Code Change After That

# Build with new version tag
docker build -t daksh12398/testingapp:02 .

# Push new version to Docker Hub
docker push daksh12398/testingapp:02

# Tell Kubernetes to update to new version
# my-webapp -> create deployment k time naam dete hai
# testingapp - container hai jo deployment pe jake pod pe jake milega
# last m image jo dockerhub m likhi hogi push command k baad vali and version jo build kiya h naya
kubectl set image deployment my-webapp testingapp=daksh12398/testingapp:02

Kubernetes rolling update starts automatically. No downtime.


Go to Any Specific Version

Same command works for going to any version — old or new. Just change the tag.

# Go to version 01
kubectl set image deployment my-webapp testingapp=daksh12398/testingapp:01

# Go to version 03
kubectl set image deployment my-webapp testingapp=daksh12398/testingapp:03

As long as that version was pushed to Docker Hub, Kubernetes can pull and run it.