7.10 Service更新

项目初始化

# 在swarm-manager节点上
docker network create -d overlay demo
docker service create --name web -p 8080:5000 --network demo xiaopeng163/python-flask-demo:1.0
docker service scale web=3

持续访问,模拟热更新的过程

# 在swarm-work2节点上
[vagrant@swarm-work2 ~]$ sh -c "while true;do curl 127.0.0.1:8080 && sleep 1;done"

项目升级

# 在swarm-manager节点上
docker service update --image xiaopeng163/python-flask-demo:2.0 web

持续访问的结果

从1.0逐步地过渡到2.0

hello docker, version 1.0
hello docker, version 1.0
hello docker, version 1.0
hello docker, version 1.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 1.0
hello docker, version 2.0
hello docker, version 2.0
hello docker, version 2.0
hello docker, version 2.0

Docker Stack的更新

在更新了docker-compose.yml之后,再次执行一次deploy指令即可

# 并不存在update指令
[vagrant@swarm-manager wordpress-overlay]$ docker stack
Usage:    docker stack COMMAND
Manage Docker stacks
Commands:
  deploy Deploy a new stack or update an existing stack
  ls List stacks
  ps List the tasks in the stack
  rm Remove one or more stacks
  services List the services in the stack

你可能感兴趣的:(docker)