Rolling Back Services in Docker

docker service rollback
11 July 2025

Introduction to Rolling Back Services in Docker


Docker, as a powerful platform for developing and deploying applications, offers multiple options for managing various services. One of these options is the ability to "rollback" services. This means that if a change in a service creates an issue, you can easily revert to a previous version of that service.


This feature is particularly useful because, in the world of development, new changes in code and deployments frequently occur. It may happen that a change disrupts the service’s performance, and in such cases, rolling back the service to its previous state can resolve many issues.


To roll back services in Docker, we typically use the Docker command line and the commands related to it. We will discuss how to execute this process and provide some example code to assist you.


Finally, it is important to remember that before executing any changes on services, there should always be a previous version of the service stored. This point can help you quickly return to the previous state in case of a problem after a change, preventing long downtimes in your service.


Code for Rolling Back a Service in Docker


# To view the previous versions of Docker services
docker service ls

# To roll back a service to its previous version
docker service update --rollback <service_name>

Command Explanations


First Command: docker service ls
This command is used to view the list of Docker services and their versions. By executing this command, you can see which services are currently running and what versions they are referring to.


Second Command: docker service update --rollback <service_name>
This command is used to roll back a specific service to its previous version. Simply replace the service name in <service_name> with the name of the service you wish to revert to its last working version.


FAQ

?

Why should I use the rollback capability of services?

?

Can I roll back a service multiple times?

?

How does rolling back a service affect system performance?

?

Is it possible to roll back a service to a specific version?