The Case of the Zombie Code: Why my EC2 refused to update 🕵️‍♂️

Published: (January 14, 2026 at 10:07 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

The Culprit? Docker’s local image cache

Docker prefers to reuse an image it already has tagged latest. When you tell it to run the latest image, it checks its local cache first. If it finds an image with the latest tag, it assumes it’s up‑to‑date and skips pulling the new version, even if the contents have changed.

Investigation: How to Force a “Search and Seizure”

Step 1 – Prove who you are (ECR login)

aws ecr get-login-password --region YOUR_REGION \
  | docker login --username AWS --password-stdin YOUR_ECR_REGISTRY

Step 2 – Stop the “imposter” container

docker stop backend-app
docker rm backend-app

Step 3 – Delete the cached image (the cache buster)

docker rmi YOUR_ECR_REGISTRY/YOUR_REPO:latest

Step 4 – Pull the fresh image and run it

docker pull YOUR_ECR_REGISTRY/YOUR_REPO:latest

docker run -d --name backend-app -p 8081:8081 \
  --restart always YOUR_ECR_REGISTRY/YOUR_REPO:latest

The “Senior Dev” Advice

Use the commit SHA as your tag

  • Build and tag the image with the Git commit SHA (e.g., my-app:8f2a4b1).
  • Have your EC2 deployment script request that specific SHA.
  • Docker will see that it doesn’t have the exact version in its cache and will pull it automatically, eliminating “zombie” deployments.

Closing Thoughts

Cache issues can waste hours of debugging. Using immutable tags like commit SHAs helps ensure you always run the intended code version.


Tags: #Docker #DevOps #EC2 #ECR

Back to Blog

Related posts

Read more »

Rapg: TUI-based Secret Manager

We've all been there. You join a new project, and the first thing you hear is: > 'Check the pinned message in Slack for the .env file.' Or you have several .env...

Technology is an Enabler, not a Saviour

Why clarity of thinking matters more than the tools you use Technology is often treated as a magic switch—flip it on, and everything improves. New software, pl...