当前位置:网站首页>11. Service update

11. Service update

2020-11-07 16:43:48 Taizhu-yj

establish overlay gateway

docker create network --name demo overlay

establish Service

docker service create --name web --publish 8080:5000 --network demo taizhuyj/python-flask-demo:1.0

Write a script , Polling service

sh -c "while true; do curl 127.0.0.1:8080&&sleep 1; done"

 Request once per second service service , Return results :
hello docker, version 1.0

to update Service, I hope the business will not be interrupted in the process

1. For those that need to be updated Service Make one scale, Expand horizontally first , Otherwise, the update service will stop .
docker service scale web=2
2. Yes Service updated image
docker service update --help  View update commands 
docker service update --image xiaopeng163/python-flask-demo:2.0 web
3. View the polling results , With the new version updated , The result of the request is made by 
hello docker, version 1.0
 Become simultaneous 
hello docker, version 1.0
hello docker, version 2.0
 With scale All updates , It's going to be all 
hello docker, version 2.0
hello docker, version 2.0

see Service Information

docker service ps web
 There will be more than one web Information , among version1.0 already shutdown 了 , And the new update version2.0 is Running, Indicates that the update was successful .

Update port

docker service update --publish-rm 8080:5000 --publish-add 8080:5000 web

 Update of network port , Can't do without interruption of service 

 

版权声明
本文为[Taizhu-yj]所创,转载请带上原文链接,感谢