✦ For everyone, free.

Practical knowledge for real and everyday life

Home

13.2.3 Rollback Strategies

A focused guide to Rollback Strategies, connecting core concepts with practical Docker and container operations.

Rollback strategies define how a deployment can be quickly reverted to a previously known-good state when a newly deployed image turns out to have an issue, an essential safety mechanism for any CI/CD pipeline, since even thorough pre-deployment validation can't catch every possible production issue.

Why a Rollback Plan Should Exist Before It's Ever Needed

Determining how a rollback will actually happen after an issue has already occurred, under the pressure of an active incident, is considerably riskier than having a clear, already-tested rollback procedure established in advance.

kubectl rollout undo deployment/myapp

Having a command like this ready and understood in advance means a rollback can happen quickly and confidently when actually needed, rather than being figured out under pressure.

Why Immutable Image Promotion Directly Enables Reliable Rollback

Since each promoted image is tied to a specific, immutable artifact (a commit SHA tag or content digest), reverting simply means redeploying whichever specific prior image was previously known to be working.

docker tag registry.example.com/myapp:abc123 registry.example.com/myapp:production
docker push registry.example.com/myapp:production

This rollback redeploys the exact, previously validated image associated with an earlier, known-good commit.

Why Database Migrations Complicate Simple Rollback

An image rollback alone doesn't undo a database schema migration that the new version may have already applied — a genuinely safe rollback strategy needs to account for this, either through backward-compatible migrations or a corresponding migration rollback step.

npm run migrate:down
Testing a Rollback Procedure Before It's Genuinely Needed

Periodically practicing an actual rollback, in a non-production environment, validates that the documented procedure genuinely works as expected.

kubectl rollout undo deployment/myapp --to-revision=2
Why Rollback Strategies Matter

Having a clear, tested rollback procedure — accounting for both the application image and any accompanying database state — is an essential safety net for any production deployment process, providing a reliable way to recover quickly when an issue is discovered after deployment.

Content in this section