2017-07-20 04:32:51 -04:00
|
|
|
# service rollback
|
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
<!---MARKER_GEN_START-->
|
2017-07-20 04:32:51 -04:00
|
|
|
Revert changes to a service's configuration
|
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
### Options
|
|
|
|
|
2024-07-03 02:29:57 -04:00
|
|
|
| Name | Type | Default | Description |
|
|
|
|
|:-----------------|:-------|:--------|:----------------------------------------------------------------|
|
|
|
|
| `-d`, `--detach` | `bool` | | Exit immediately instead of waiting for the service to converge |
|
|
|
|
| `-q`, `--quiet` | `bool` | | Suppress progress output |
|
2023-01-06 13:04:05 -05:00
|
|
|
|
|
|
|
|
|
|
|
<!---MARKER_GEN_END-->
|
2017-07-20 04:32:51 -04:00
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2018-12-23 06:27:52 -05:00
|
|
|
Roll back a specified service to its previous version from the swarm.
|
|
|
|
|
2024-08-16 05:02:10 -04:00
|
|
|
> [!NOTE]
|
2020-04-19 11:08:37 -04:00
|
|
|
> This is a cluster management command, and must be executed on a swarm
|
|
|
|
> manager node. To learn about managers and workers, refer to the
|
|
|
|
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
|
|
|
|
> documentation.
|
2017-07-20 04:32:51 -04:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Roll back to the previous version of a service
|
|
|
|
|
|
|
|
Use the `docker service rollback` command to roll back to the previous version
|
|
|
|
of a service. After executing this command, the service is reverted to the
|
|
|
|
configuration that was in place before the most recent `docker service update`
|
|
|
|
command.
|
|
|
|
|
|
|
|
The following example creates a service with a single replica, updates the
|
|
|
|
service to use three replicas, and then rolls back the service to the
|
|
|
|
previous version, having one replica.
|
|
|
|
|
|
|
|
Create a service with a single replica:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-07-20 04:32:51 -04:00
|
|
|
$ docker service create --name my-service -p 8080:80 nginx:alpine
|
|
|
|
```
|
|
|
|
|
|
|
|
Confirm that the service is running with a single replica:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-07-20 04:32:51 -04:00
|
|
|
$ docker service ls
|
|
|
|
|
|
|
|
ID NAME MODE REPLICAS IMAGE PORTS
|
|
|
|
xbw728mf6q0d my-service replicated 1/1 nginx:alpine *:8080->80/tcp
|
|
|
|
```
|
|
|
|
|
|
|
|
Update the service to use three replicas:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-07-20 04:32:51 -04:00
|
|
|
$ docker service update --replicas=3 my-service
|
|
|
|
|
|
|
|
$ docker service ls
|
|
|
|
|
|
|
|
ID NAME MODE REPLICAS IMAGE PORTS
|
|
|
|
xbw728mf6q0d my-service replicated 3/3 nginx:alpine *:8080->80/tcp
|
|
|
|
```
|
|
|
|
|
|
|
|
Now roll back the service to its previous version, and confirm it is
|
|
|
|
running a single replica again:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-07-20 04:32:51 -04:00
|
|
|
$ docker service rollback my-service
|
|
|
|
|
|
|
|
$ docker service ls
|
|
|
|
|
|
|
|
ID NAME MODE REPLICAS IMAGE PORTS
|
|
|
|
xbw728mf6q0d my-service replicated 1/1 nginx:alpine *:8080->80/tcp
|
|
|
|
```
|
|
|
|
|
|
|
|
## Related commands
|
|
|
|
|
|
|
|
* [service create](service_create.md)
|
|
|
|
* [service inspect](service_inspect.md)
|
|
|
|
* [service logs](service_logs.md)
|
|
|
|
* [service ls](service_ls.md)
|
|
|
|
* [service ps](service_ps.md)
|
|
|
|
* [service rm](service_rm.md)
|
|
|
|
* [service scale](service_scale.md)
|
|
|
|
* [service update](service_update.md)
|