github.com/kobeld/docker@v1.12.0-rc1/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  [menu.main]
     7  identifier="swarm-tutorial-rolling-update"
     8  parent="swarm-tutorial"
     9  weight=20
    10  advisory = "rc"
    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 new Redis
    18  service and upgrade the service using rolling updates.
    19  
    20  1. If you haven't already, open a terminal and ssh into the machine where you
    21  run your manager node. For example, the tutorial uses a machine named
    22  `manager1`.
    23  
    24  2. Deploy Redis 3.0.6 to all nodes in the Swarm and configure
    25  the swarm to update one node every 10 seconds:
    26  
    27      ```bash
    28      $ docker service create --replicas 3 --name redis --update-delay 10s --update-parallelism 1 redis:3.0.6
    29  
    30      8m228injfrhdym2zvzhl9k3l0
    31      ```
    32  
    33      You configure the rolling update policy at service deployment time.
    34  
    35      The `--update-parallelism` flag configures the number of service tasks
    36      to update simultaneously.
    37  
    38      The `--update-delay` flag configures the time delay between updates to a
    39      service task or sets of tasks. You can describe the time `T` as a
    40      combination of the number of seconds `Ts`, minutes `Tm`, or hours `Th`. So
    41      `10m30s` indicates a 10 minute 30 second delay.
    42  
    43  3. Inspect the `redis` service:
    44  
    45      ```
    46      $ docker service inspect redis --pretty
    47  
    48      ID:		75kcmhuf8mif4a07738wttmgl
    49      Name:		redis
    50      Mode:		REPLICATED
    51       Scale:	3
    52      Placement:
    53       Strategy:	SPREAD
    54      UpdateConfig:
    55       Parallelism:	1
    56       Delay:		10s
    57      ContainerSpec:
    58       Image:		redis:3.0.6
    59      ```
    60  
    61  4. Now you can update the container image for `redis`. Swarm applies the update
    62  to nodes according to the `UpdateConfig` policy:
    63  
    64      ```bash
    65      $ docker service update --image redis:3.0.7 redis
    66      redis
    67      ```
    68  
    69  5. Run `docker service inspect --pretty redis` to see the new image in the
    70  desired state:
    71  
    72      ```
    73      docker service inspect --pretty redis
    74  
    75      ID:		1yrcci9v8zj6cokua2eishlob
    76      Name:		redis
    77      Mode:		REPLICATED
    78       Scale:		3
    79      Placement:
    80       Strategy:	SPREAD
    81      UpdateConfig:
    82       Parallelism:	1
    83       Delay:		10s
    84     ContainerSpec:
    85     Image:		redis:3.0.7
    86     ```
    87  
    88  6. Run `docker service tasks <TASK-ID>` to watch the rolling update:
    89  
    90      ```
    91      $ docker service tasks redis
    92  
    93      ID                         NAME     SERVICE  IMAGE        DESIRED STATE  LAST STATE          NODE
    94      5409nu4crb0smamziqwuug67u  redis.1  redis    redis:3.0.7  RUNNING        RUNNING 21 seconds  worker2
    95      b8ezq58zugcg1trk8k7jrq9ym  redis.2  redis    redis:3.0.7  RUNNING        RUNNING 1 seconds   worker1
    96      cgdcbipxnzx0y841vysiafb64  redis.3  redis    redis:3.0.7  RUNNING        RUNNING 11 seconds  worker1
    97      ```
    98  
    99      Before Swarm updates all of the tasks, you can see that some are running
   100      `redis:3.0.6` while others are running `redis:3.0.7`. The output above shows
   101      the state once the rolling updates are done. You can see that each instances
   102      entered the `RUNNING` state in 10 second increments.
   103  
   104  Next, learn about how to [drain a node](drain-node.md) in the Swarm.
   105  
   106  <p style="margin-bottom:300px">&nbsp;</p>