concept rollback in category docker

appears as: rollback, rollbacks, rollback
Learn Docker in a Month of Lunches

This is an excerpt from Manning's book Learn Docker in a Month of Lunches.

The rollback process works in the same way as the update process, with a staged rollout, but it uses the service specification from before the most recent update, so you don’t need to provide the image tag. That’s very useful if an update breaks the application in a way that Docker doesn’t notice, which could happen if you don’t have health checks or if your checks aren’t detailed enough. In that case, when you discover the app is broken, you just run the rollback command and you don’t need to frantically try and find the details of the previous service spec. My output is in figure 12.11, where you can see the replicas from all the deployments, and the service logs from the most recent replicas--the update to 2.0 and the rollback to 1.0.

Tuning update configuration might sound like a topic you can safely skip, but I can tell you from my own experience that it will cause you pain if you don’t understand how rollouts work and how you can modify the default behavior. This chapter is focused on Docker Swarm, but all orchestrators have a staged rollout process that works in a similar way. Knowing how updates and rollbacks work lets you experiment to find the settings that fit for your app so you can deploy to production as often as you like, confident that the update will either work successfully or automatically roll back to the previous version.

This time you’ll see the rollback happens more quickly, but only marginally because there are only a small number of replicas in the API service, all running on my single node. You can see how important this would be in a larger deployment that might have 100 replicas running across 20 nodes--rolling back each replica individually would prolong the amount of time your app might be running below capacity or in an unstable state. You can see my output in figure 14.7--I was quick enough this time to catch the rollback just as it had triggered, so the state shows the rollback is starting.

Figure 14.7 Specifying custom rollback settings means a failed rollout gets fixed faster.

When you run this yourself, take a look at the full service configuration when the rollback has completed--you’ll see that the rollback configuration has been reset to the default values. That’s guaranteed confusion right there, because you’ll be thinking the rollback config wasn’t applied. But actually it’s because the whole service configuration got rolled back, and that includes the rollback setup--the replicas were rolled back in line with the new policy, and then the rollback policy was rolled back. Next time you deploy, you’ll need to make sure you keep adding the update and rollback configs, or they’ll be updated back to the default settings.

This is where having multiple override files gets dangerous, because they’re all necessary and they all need to be specified in the correct order. Normally you wouldn’t split out settings for one environment across multiple files; I’ve just done that to make our journey through updates and rollbacks easier to follow. Typically you’d have the core Compose file, an environment override file, and possibly a version override file. We’ll take that approach for the final deployment, fixing the v5 issue and getting the app working again.

Docker in Action, Second Edition

This is an excerpt from Manning's book Docker in Action, Second Edition.

hello-world
overall progress: rolling back update: 2 out of 3 tasks
1/3: running  [>                  ]
2/3: starting [=====>             ]
3/3: running  [>                  ]
rollback: update rolled back due to failure or early termination of 
task tdpv6fud16e4nbg3tx2jpikah
service rolled back: rollback completed