Home Explore Blog Models CI



docker

2nd chunk of `content/manuals/engine/swarm/swarm-tutorial/rolling-update.md`
1eb4c47067904335ccd9aba53ab676597f465c10c505d44c0000000100000eb6
    `RUNNING`, the scheduler schedules another task to update until all tasks
    are updated. If at any time during an update a task returns `FAILED`, the
    scheduler pauses the update. You can control the behavior using the
    `--update-failure-action` flag for `docker service create` or
    `docker service update`.

3.  Inspect the `redis` service:

    ```console
    $ docker service inspect --pretty redis

    ID:             0u6a4s31ybk7yw2wyvtikmu50
    Name:           redis
    Service Mode:   Replicated
     Replicas:      3
    Placement:
     Strategy:	    Spread
    UpdateConfig:
     Parallelism:   1
     Delay:         10s
    ContainerSpec:
     Image:         redis:7.4.0
    Resources:
    Endpoint Mode:  vip
    ```

4.  Now you can update the container image for `redis`. The swarm  manager
    applies the update to nodes according to the `UpdateConfig` policy:

    ```console
    $ docker service update --image redis:7.4.1 redis
    redis
    ```

    The scheduler applies rolling updates as follows by default:

    * Stop the first task.
    * Schedule update for the stopped task.
    * Start the container for the updated task.
    * If the update to a task returns `RUNNING`, wait for the
      specified delay period then start the next task.
    * If, at any time during the update, a task returns `FAILED`, pause the
      update.

5.  Run `docker service inspect --pretty redis` to see the new image in the
    desired state:

    ```console
    $ docker service inspect --pretty redis

    ID:             0u6a4s31ybk7yw2wyvtikmu50
    Name:           redis
    Service Mode:   Replicated
     Replicas:      3
    Placement:
     Strategy:	    Spread
    UpdateConfig:
     Parallelism:   1
     Delay:         10s
    ContainerSpec:
     Image:         redis:7.4.1
    Resources:
    Endpoint Mode:  vip
    ```

    The output of `service inspect` shows if your update paused due to failure:

    ```console
    $ docker service inspect --pretty redis

    ID:             0u6a4s31ybk7yw2wyvtikmu50
    Name:           redis
    ...snip...
    Update status:
     State:      paused
     Started:    11 seconds ago
     Message:    update paused due to failure or early termination of task 9p7ith557h8ndf0ui9s0q951b
    ...snip...
    ```

    To restart a paused update run `docker service update <SERVICE-ID>`. For example:

    ```console
    $ docker service update redis
    ```

    To avoid repeating certain update failures, you may need to reconfigure the
    service by passing flags to `docker service update`.

6.  Run `docker service ps <SERVICE-ID>` to watch the rolling update:

    ```console
    $ docker service ps redis

    NAME                                   IMAGE        NODE       DESIRED STATE  CURRENT STATE            ERROR
    redis.1.dos1zffgeofhagnve8w864fco      redis:7.4.1  worker1    Running        Running 37 seconds
     \_ redis.1.88rdo6pa52ki8oqx6dogf04fh  redis:7.4.0  worker2    Shutdown       Shutdown 56 seconds ago
    redis.2.9l3i4j85517skba5o7tn5m8g0      redis:7.4.1  worker2    Running        Running About a minute
     \_ redis.2.66k185wilg8ele7ntu8f6nj6i  redis:7.4.0  worker1    Shutdown       Shutdown 2 minutes ago
    redis.3.egiuiqpzrdbxks3wxgn8qib1g      redis:7.4.1  worker1    Running        Running 48 seconds
     \_ redis.3.ctzktfddb2tepkr45qcmqln04  redis:7.4.0  mmanager1  Shutdown       Shutdown 2 minutes ago
    ```

    Before Swarm updates all of the tasks, you can see that some are running
    `redis:7.4.0` while others are running `redis:7.4.1`. The output above shows
    the state once the rolling updates are done.

## Next steps

Next, you'll learn how to drain a node in the swarm.

{{< button text="Drain a node" url="drain-node.md" >}}

Title: Performing and Monitoring Rolling Updates in Docker Swarm
Summary
This section details how Docker Swarm's rolling updates are applied, including stopping a task, scheduling updates, and managing failures. It provides commands to inspect the service, restart paused updates, and monitor the update process using `docker service ps`. The example demonstrates how to observe tasks running different versions of the image during the update process and how to check for paused updates due to failures. The next step is to learn how to drain a node.