Docker零停机时间

时间:2018-06-06 11:16:36

标签: docker nginx swarm

我希望实现零停机时间。我创建了一个包含5个副本的服务并部署到堆栈中,然后我想用一些新的更改来更新现有服务,并在没有停机时间的情况下部署到堆栈中。

version: "3" services: hello-html: image: hello-html:latest deploy: replicas: 5 resources: limits: cpus: "0.1" memory: 50M restart_policy: condition: on-failure ports: - 80:80 networks: mynetwork: driver: overlay

3 个答案:

答案 0 :(得分:0)

使用Kubernetes容器作为服务(CAAS)以零停机时间更新应用程序

答案 1 :(得分:0)

使用泊坞窗服务更新 - 请参阅https://docs.docker.com/engine/reference/commandline/service_update/了解语法。

使用docker service ls获取服务列表并知道要更新哪个服务。

答案 2 :(得分:0)

我需要为我的服务设置以下选项:

--update-order start-first
--update-delay 1m # depends how long your tasks needs untill it's ready

我还必须为我的api实现HealthCheck

start period 1m

这样,在任务准备好之前,docker不会重定向流量。

例如:

HEALTHCHECK --interval=5m --timeout=3s --start-period=1m \
  CMD curl -f http://localhost/ || exit 1
相关问题