Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to scroll to update Service

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to update Service scrolling. maybe many people don't know much about it. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

In the previous lab, we deployed multiple copies of the service, and this section discusses how to scroll to update each copy.

Rolling updates reduce the risk of applying updates, and if one copy fails, the entire update is paused and other replicas can continue to provide services. At the same time, in the process of updating, there is always a copy running, so it also ensures the continuity of the business.

Next we will deploy a three-copy service, which uses httpd:2.2.31 for the mirror, and then updates it to httpd:2.2.32.

Create a service:

Docker service create-name my_web-replicas=3 httpd:2.2.31

Update service to httpd:2.2.32:

Docker service update-image httpd:2.2.32 my_web

-- image specifies the new image.

Swarm will perform a rolling update as follows:

Stop the first copy.

Schedule the task and select worker node.

Start the copy with the new image on worker.

If the copy (container) runs successfully, continue to update the next copy; if it fails, pause the entire update process.

Docker service ps to view the update results.

All three copies have been updated to httpd:2.2.32.

By default, Swarm updates only one copy at a time, and there is no wait time between the two copies. We can set the number of copies of parallel updates through-- update-parallelism, and specify the interval between rolling updates through-- update-delay.

For example, execute the following command:

Docker service update--replicas 6-- update-parallelism 2-- update-delay 1m30s my_web

Service has been increased to six copies, two copies at a time, at intervals of one and a half minutes.

Docker service inspect views the current configuration of service.

Docker service ps ensures that six copies are in a normal state.

Update the mirror to httpd:2.4.16 by executing the following command.

Docker service update-image httpd:2.4.16 my_web

Wait a moment to check the status of the update.

Four copies have been updated to httpd:2.4.16, and from the startup time point of view, they are indeed carried out in two batches, with an interval of 90 seconds, two copies at a time.

Swarm also has a convenient feature is rollback, if the update results are not satisfactory, you can use-- rollback to quickly restore to the state before the update.

All copies of service have been restored to httpd:2.2.32.

Note that-- rollback can only be rolled back to the state it was before the last docker service update execution, not indefinitely.

After reading the above, do you have any further understanding of how to scroll and update Service? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report