gpt4 book ai didi

docker - 交错的Docker堆栈部署

转载 作者:行者123 更新时间:2023-12-02 20:04:31 25 4
gpt4 key购买 nike

我已经创建了一个docker镜像来运行清漆。它传递给清漆.vcl配置文件,设置了自定义端口,并且可以正常工作。
我将在一台服务器上部署多个具有自定义配置和端口的容器。所以我写了一个docker-compose.yml文件来定义它。使用docker stack deploy我可以让它们全部运行。

如果要调整Docker镜像,就会出现问题。
目前,我正在更新docker-compose.yml文件中的版本,然后重新运行docker stack deploy命令,该命令将关闭所有 docker 并再次启动它们。
我想错开重新部署,以便一次更新一次,因为一次执行所有操作会导致服务器上的大量负载,而随着我们的扩展,这种负载只会变得更糟。

我怎样才能做到这一点?
有没有更好的方法来解决这种情况?

提前致谢!

当前的docker-compose.yml文件:

version: "3"
services:
test-site-one:
image: test/varnish:v7.3
deploy:
restart_policy:
condition: on-failure
ports:
- "8080:80"
volumes:
- /path/to/magento.vcl:/etc/varnish/default.vcl
test-site-two:
image: test/varnish:v7.3
deploy:
restart_policy:
condition: on-failure
ports:
- "8081:80"
volumes:
- /path/to/magento.vcl:/etc/varnish/default.vcl
test-site-three:
image: test/varnish:v7.3
deploy:
restart_policy:
condition: on-failure
ports:
- "8082:80"
volumes:
- /path/tp/magento.vcl:/etc/varnish/default.vcl

最佳答案

您可以按照https://docs.docker.com/compose/compose-file/#update_config所述在Compose文件中指定update_config。

根据文档:

Configures how the service should be updated. Useful for configuring rolling updates.

  • parallelism: The number of containers to update at a time.
  • delay: The time to wait between updating a group of containers.
  • failure_action: What to do if an update fails. One of continue, rollback, or pause (default: pause).
  • monitor: Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s).
  • max_failure_ratio: Failure rate to tolerate during an update.
  • order: Order of operations during updates. One of stop-first (old task is stopped before starting new one), or start-first (new task is started first, and the running tasks briefly overlap) (default stop-first) Note: Only supported for v3.4 and higher.


version: '3.4'
services:
vote:
image: dockersamples/examplevotingapp_vote:before
depends_on:
- redis
deploy:
replicas: 2
update_config:
parallelism: 2
delay: 10s
order: stop-first

关于docker - 交错的Docker堆栈部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50925692/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com