github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/service_rollback.md (about) 1 # service rollback 2 3 <!---MARKER_GEN_START--> 4 Revert changes to a service's configuration 5 6 ### Options 7 8 | Name | Type | Default | Description | 9 |:-----------------|:-----|:--------|:----------------------------------------------------------------| 10 | `-d`, `--detach` | | | Exit immediately instead of waiting for the service to converge | 11 | `-q`, `--quiet` | | | Suppress progress output | 12 13 14 <!---MARKER_GEN_END--> 15 16 ## Description 17 18 Roll back a specified service to its previous version from the swarm. 19 20 > **Note** 21 > 22 > This is a cluster management command, and must be executed on a swarm 23 > manager node. To learn about managers and workers, refer to the 24 > [Swarm mode section](https://docs.docker.com/engine/swarm/) in the 25 > documentation. 26 27 ## Examples 28 29 ### Roll back to the previous version of a service 30 31 Use the `docker service rollback` command to roll back to the previous version 32 of a service. After executing this command, the service is reverted to the 33 configuration that was in place before the most recent `docker service update` 34 command. 35 36 The following example creates a service with a single replica, updates the 37 service to use three replicas, and then rolls back the service to the 38 previous version, having one replica. 39 40 Create a service with a single replica: 41 42 ```console 43 $ docker service create --name my-service -p 8080:80 nginx:alpine 44 ``` 45 46 Confirm that the service is running with a single replica: 47 48 ```console 49 $ docker service ls 50 51 ID NAME MODE REPLICAS IMAGE PORTS 52 xbw728mf6q0d my-service replicated 1/1 nginx:alpine *:8080->80/tcp 53 ``` 54 55 Update the service to use three replicas: 56 57 ```console 58 $ docker service update --replicas=3 my-service 59 60 $ docker service ls 61 62 ID NAME MODE REPLICAS IMAGE PORTS 63 xbw728mf6q0d my-service replicated 3/3 nginx:alpine *:8080->80/tcp 64 ``` 65 66 Now roll back the service to its previous version, and confirm it is 67 running a single replica again: 68 69 ```console 70 $ docker service rollback my-service 71 72 $ docker service ls 73 74 ID NAME MODE REPLICAS IMAGE PORTS 75 xbw728mf6q0d my-service replicated 1/1 nginx:alpine *:8080->80/tcp 76 ``` 77 78 ## Related commands 79 80 * [service create](service_create.md) 81 * [service inspect](service_inspect.md) 82 * [service logs](service_logs.md) 83 * [service ls](service_ls.md) 84 * [service ps](service_ps.md) 85 * [service rm](service_rm.md) 86 * [service scale](service_scale.md) 87 * [service update](service_update.md)