github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/service_rollback.md (about)

     1  ---
     2  title: "service rollback"
     3  description: "The service rollback command description and usage"
     4  keywords: "service, rollback"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/cli GitHub
     8       repository at https://github.com/docker/cli/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # service rollback
    17  
    18  ```markdown
    19  Usage:	docker service rollback SERVICE
    20  
    21  Revert changes to a service's configuration
    22  
    23  Options:
    24    -d, --detach       Exit immediately instead of waiting for the service to converge (default true)
    25        --help         Print usage
    26    -q, --quiet        Suppress progress output
    27  ```
    28  
    29  ## Description
    30  
    31  Roll back a specified service to its previous version from the swarm. This command must be run
    32  targeting a manager node.
    33  
    34  ## Examples
    35  
    36  ### Roll back to the previous version of a service
    37  
    38  Use the `docker service rollback` command to roll back to the previous version
    39  of a service. After executing this command, the service is reverted to the
    40  configuration that was in place before the most recent `docker service update`
    41  command.
    42  
    43  The following example creates a service with a single replica, updates the
    44  service to use three replicas, and then rolls back the service to the
    45  previous version, having one replica.
    46  
    47  Create a service with a single replica:
    48  
    49  ```bash
    50  $ docker service create --name my-service -p 8080:80 nginx:alpine
    51  ```
    52  
    53  Confirm that the service is running with a single replica:
    54  
    55  ```bash
    56  $ docker service ls
    57  
    58  ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
    59  xbw728mf6q0d        my-service          replicated          1/1                 nginx:alpine        *:8080->80/tcp
    60  ```
    61  
    62  Update the service to use three replicas:
    63  
    64  ```bash
    65  $ docker service update --replicas=3 my-service
    66  
    67  $ docker service ls
    68  
    69  ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
    70  xbw728mf6q0d        my-service          replicated          3/3                 nginx:alpine        *:8080->80/tcp
    71  ```
    72  
    73  Now roll back the service to its previous version, and confirm it is
    74  running a single replica again:
    75  
    76  ```bash
    77  $ docker service rollback my-service
    78  
    79  $ docker service ls
    80  
    81  ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
    82  xbw728mf6q0d        my-service          replicated          1/1                 nginx:alpine        *:8080->80/tcp
    83  ```
    84  
    85  ## Related commands
    86  
    87  * [service create](service_create.md)
    88  * [service inspect](service_inspect.md)
    89  * [service logs](service_logs.md)
    90  * [service ls](service_ls.md)
    91  * [service ps](service_ps.md)
    92  * [service rm](service_rm.md)
    93  * [service scale](service_scale.md)
    94  * [service update](service_update.md)