Required inputs
Before starting the upgrade, ensure you have:- Target release version (e.g., v3.9.52)
- Container registry access credentials
- Access to the Swarm manager node
Pre-upgrade checklist
Before performing any upgrade:-
Backup critical data:
- Database snapshots (TiDB/TiKV)
- Redis persistence files
- Configuration files
-
Verify current system health:
- Test the upgrade in a staging environment first
- Schedule maintenance window (if needed for major upgrades)
- Notify team members of the upgrade
Upgrade execution steps
Upgrades should be performed during low-traffic periods whenever possible.Step 1: Pull latest images
Step 2: Apply updates using the update script
To update services without full redeploy:Step 3: Monitor the rollout
Watch service updates in real-time:Step 4: Verify health checks
Ensure new replicas pass health checks:Rolling updates
Docker Swarm performs rolling updates automatically when using./update.sh or manual service updates:
- Deploy new service replicas alongside existing ones
- Gradually shift traffic to the updated replicas
- Retire older replicas only after health checks pass
Configure update behavior
Control rolling update parameters:Database migrations
Step 1: Backup database
Step 2: Test migration in staging
Always test migrations in a staging environment before production.Step 3: Run migration
Best practices
- Prefer backward-compatible schema changes
- Avoid dropping or renaming columns while serving live traffic
- Use feature flags to decouple code deployment from schema changes
- Keep migrations idempotent (safe to run multiple times)
Post-upgrade verification
After upgrade completes:-
Check service status:
-
Verify application health:
-
Monitor logs for errors:
- Check metrics and dashboards (Prometheus/Grafana) for latency, error rates, and resource spikes
- Test critical user flows (login, messaging, etc.)
Rollback procedures
If issues are detected after upgrade:Automatic rollback
Docker Swarm can automatically rollback on failure:Manual rollback to previous image
Database rollback
If database migration needs reverting:Rollback checklist
- Revert service images to previous versions
- Rollback database migrations if schema changed
- Restore configuration files if modified
- Validate application behavior and data integrity
- Monitor the system for 15–30 minutes before restoring full traffic
- Document the issue and root cause for post-mortem