summaryrefslogtreecommitdiff
path: root/devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Frolling-update%2Findex.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Frolling-update%2Findex.html')
-rw-r--r--devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Frolling-update%2Findex.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Frolling-update%2Findex.html b/devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Frolling-update%2Findex.html
new file mode 100644
index 00000000..3091ea58
--- /dev/null
+++ b/devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Frolling-update%2Findex.html
@@ -0,0 +1,69 @@
+<h1>Apply rolling updates to a service</h1>
+
+<p>In a previous step of the tutorial, you <a href="../scale-service/index">scaled</a> the number of instances of a service. In this part of the tutorial, you deploy a service based on the Redis 3.0.6 container tag. Then you upgrade the service to use the Redis 3.0.7 container image using rolling updates.</p> <ol> <li> <p>If you haven’t already, open a terminal and ssh into the machine where you run your manager node. For example, the tutorial uses a machine named <code class="language-plaintext highlighter-rouge">manager1</code>.</p> </li> <li> <p>Deploy your Redis tag to the swarm and configure the swarm with a 10 second update delay. Note that the following example shows an older Redis tag:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker service create \
+ --replicas 3 \
+ --name redis \
+ --update-delay 10s \
+ redis:3.0.6
+
+0u6a4s31ybk7yw2wyvtikmu50
+</pre></div> <p>You configure the rolling update policy at service deployment time.</p> <p>The <code class="language-plaintext highlighter-rouge">--update-delay</code> flag configures the time delay between updates to a service task or sets of tasks. You can describe the time <code class="language-plaintext highlighter-rouge">T</code> as a combination of the number of seconds <code class="language-plaintext highlighter-rouge">Ts</code>, minutes <code class="language-plaintext highlighter-rouge">Tm</code>, or hours <code class="language-plaintext highlighter-rouge">Th</code>. So <code class="language-plaintext highlighter-rouge">10m30s</code> indicates a 10 minute 30 second delay.</p> <p>By default the scheduler updates 1 task at a time. You can pass the <code class="language-plaintext highlighter-rouge">--update-parallelism</code> flag to configure the maximum number of service tasks that the scheduler updates simultaneously.</p> <p>By default, when an update to an individual task returns a state of <code class="language-plaintext highlighter-rouge">RUNNING</code>, the scheduler schedules another task to update until all tasks are updated. If, at any time during an update a task returns <code class="language-plaintext highlighter-rouge">FAILED</code>, the scheduler pauses the update. You can control the behavior using the <code class="language-plaintext highlighter-rouge">--update-failure-action</code> flag for <code class="language-plaintext highlighter-rouge">docker service create</code> or <code class="language-plaintext highlighter-rouge">docker service update</code>.</p> </li> <li> <p>Inspect the <code class="language-plaintext highlighter-rouge">redis</code> service:</p> <div class="highlight"><pre class="highlight" data-language="">$ 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:3.0.6
+Resources:
+Endpoint Mode: vip
+</pre></div> </li> <li> <p>Now you can update the container image for <code class="language-plaintext highlighter-rouge">redis</code>. The swarm manager applies the update to nodes according to the <code class="language-plaintext highlighter-rouge">UpdateConfig</code> policy:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker service update --image redis:3.0.7 redis
+redis
+</pre></div> <p>The scheduler applies rolling updates as follows by default:</p> <ul> <li>Stop the first task.</li> <li>Schedule update for the stopped task.</li> <li>Start the container for the updated task.</li> <li>If the update to a task returns <code class="language-plaintext highlighter-rouge">RUNNING</code>, wait for the specified delay period then start the next task.</li> <li>If, at any time during the update, a task returns <code class="language-plaintext highlighter-rouge">FAILED</code>, pause the update.</li> </ul> </li> <li> <p>Run <code class="language-plaintext highlighter-rouge">docker service inspect --pretty redis</code> to see the new image in the desired state:</p> <div class="highlight"><pre class="highlight" data-language="">$ 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:3.0.7
+Resources:
+Endpoint Mode: vip
+</pre></div> <p>The output of <code class="language-plaintext highlighter-rouge">service inspect</code> shows if your update paused due to failure:</p> <div class="highlight"><pre class="highlight" data-language="">$ 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...
+</pre></div> <p>To restart a paused update run <code class="language-plaintext highlighter-rouge">docker service update &lt;SERVICE-ID&gt;</code>. For example:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker service update redis
+</pre></div> <p>To avoid repeating certain update failures, you may need to reconfigure the service by passing flags to <code class="language-plaintext highlighter-rouge">docker service update</code>.</p> </li> <li> <p>Run <code class="language-plaintext highlighter-rouge">docker service ps &lt;SERVICE-ID&gt;</code> to watch the rolling update:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker service ps redis
+
+NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
+redis.1.dos1zffgeofhagnve8w864fco redis:3.0.7 worker1 Running Running 37 seconds
+ \_ redis.1.88rdo6pa52ki8oqx6dogf04fh redis:3.0.6 worker2 Shutdown Shutdown 56 seconds ago
+redis.2.9l3i4j85517skba5o7tn5m8g0 redis:3.0.7 worker2 Running Running About a minute
+ \_ redis.2.66k185wilg8ele7ntu8f6nj6i redis:3.0.6 worker1 Shutdown Shutdown 2 minutes ago
+redis.3.egiuiqpzrdbxks3wxgn8qib1g redis:3.0.7 worker1 Running Running 48 seconds
+ \_ redis.3.ctzktfddb2tepkr45qcmqln04 redis:3.0.6 mmanager1 Shutdown Shutdown 2 minutes ago
+</pre></div> <p>Before Swarm updates all of the tasks, you can see that some are running <code class="language-plaintext highlighter-rouge">redis:3.0.6</code> while others are running <code class="language-plaintext highlighter-rouge">redis:3.0.7</code>. The output above shows the state once the rolling updates are done.</p> </li> </ol> <h2 id="whats-next">What’s next?</h2> <p>Next, learn about how to <a href="../drain-node/index">drain a node</a> in the swarm.</p>
+<p><a href="https://docs.docker.com/search/?q=tutorial">tutorial</a>, <a href="https://docs.docker.com/search/?q=cluster%20management">cluster management</a>, <a href="https://docs.docker.com/search/?q=swarm">swarm</a>, <a href="https://docs.docker.com/search/?q=service">service</a>, <a href="https://docs.docker.com/search/?q=rolling-update">rolling-update</a></p>
+<div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
+ <a href="https://docs.docker.com/engine/swarm/swarm-tutorial/rolling-update/" class="_attribution-link">https://docs.docker.com/engine/swarm/swarm-tutorial/rolling-update/</a>
+ </p>
+</div>