github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/docs/swarm/swarm-tutorial/rolling-update.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Apply rolling updates"
     4  description = "Apply rolling updates to a service on the Swarm"
     5  keywords = ["tutorial, cluster management, swarm, service, rolling-update"]
     6  advisory = "rc"
     7  [menu.main]
     8  identifier="swarm-tutorial-rolling-update"
     9  parent="swarm-tutorial"
    10  weight=20
    11  +++
    12  <![end-metadata]-->
    13  
    14  # Apply rolling updates to a service
    15  
    16  In a previous step of the tutorial, you [scaled](scale-service.md) the number of
    17  instances of a service. In this part of the tutorial, you deploy a service based
    18  on the Redis 3.0.6 container image. Then you upgrade the service to use the
    19  Redis 3.0.7 container image using rolling updates.
    20  
    21  1. If you haven't already, open a terminal and ssh into the machine where you
    22  run your manager node. For example, the tutorial uses a machine named
    23  `manager1`.
    24  
    25  2. Deploy Redis 3.0.6 to the swarm and configure the swarm to update one node
    26  every 10 seconds:
    27  
    28      ```bash
    29      $ docker service create --replicas 3 --name redis --update-delay 10s --update-parallelism 1 redis:3.0.6
    30  
    31      0u6a4s31ybk7yw2wyvtikmu50
    32      ```
    33  
    34      You configure the rolling update policy at service deployment time.
    35  
    36      The `--update-parallelism` flag configures the number of service tasks
    37      to update simultaneously.
    38  
    39      The `--update-delay` flag configures the time delay between updates to a
    40      service task or sets of tasks. You can describe the time `T` as a
    41      combination of the number of seconds `Ts`, minutes `Tm`, or hours `Th`. So
    42      `10m30s` indicates a 10 minute 30 second delay.
    43  
    44  3. Inspect the `redis` service:
    45  
    46      ```bash
    47      $ docker service inspect redis --pretty
    48  
    49      ID:		0u6a4s31ybk7yw2wyvtikmu50
    50      Name:		redis
    51      Mode:		REPLICATED
    52       Replicas:		3
    53      Placement:
    54       Strategy:	SPREAD
    55      UpdateConfig:
    56       Parallelism:	1
    57       Delay:		10s
    58      ContainerSpec:
    59       Image:		redis:3.0.6
    60      ```
    61  
    62  4. Now you can update the container image for `redis`. The swarm  manager
    63  applies the update to nodes according to the `UpdateConfig` policy:
    64  
    65      ```bash
    66      $ docker service update --image redis:3.0.7 redis
    67      redis
    68      ```
    69  
    70  5. Run `docker service inspect --pretty redis` to see the new image in the
    71  desired state:
    72  
    73      ```bash
    74      docker service inspect --pretty redis
    75  
    76      ID:		0u6a4s31ybk7yw2wyvtikmu50
    77      Name:		redis
    78      Mode:		REPLICATED
    79       Replicas:		3
    80      Placement:
    81       Strategy:	SPREAD
    82      UpdateConfig:
    83       Parallelism:	1
    84       Delay:		10s
    85      ContainerSpec:
    86       Image:		redis:3.0.7
    87     ```
    88  
    89  6. Run `docker service tasks <TASK-ID>` to watch the rolling update:
    90  
    91      ```bash
    92      $ docker service tasks redis
    93  
    94      ID                         NAME     SERVICE  IMAGE        LAST STATE              DESIRED STATE  NODE
    95      dos1zffgeofhagnve8w864fco  redis.1  redis    redis:3.0.7  Running 37 seconds      Running        worker1
    96      9l3i4j85517skba5o7tn5m8g0  redis.2  redis    redis:3.0.7  Running About a minute  Running        worker2
    97      egiuiqpzrdbxks3wxgn8qib1g  redis.3  redis    redis:3.0.7  Running 48 seconds      Running        worker1
    98      ```
    99  
   100      Before Swarm updates all of the tasks, you can see that some are running
   101      `redis:3.0.6` while others are running `redis:3.0.7`. The output above shows
   102      the state once the rolling updates are done. You can see that each instances
   103      entered the `RUNNING` state in approximately 10 second increments.
   104  
   105  Next, learn about how to [drain a node](drain-node.md) in the Swarm.