condition: on-failure delay: 10s max_attempts:3window: 120s networks: frontend: backend: volumes: db-data: 3、version 常用版本 指定Docker Compose文件格式的版本。常用版本为3.8,3.7等。 4、services 配置指令 1)container_name 指定自定义
restart_policy # 定义容器重启策略, 用于代替 restart 参数 condition # 定义容器重启策略(接受三个参数) none # 不尝试重启 on-failure # 只有当容器内部应用程序出现问题才会重启 any # 无论如何都会尝试重启(默认) delay # 尝试重启的间隔时间(默认为 0s) max_attempts # 尝试重启次数(默认一直尝试重启) wi...
depends_on不会在启动web之前等待db和redis“就绪” 版本3不再支持condition形式depends_on。 使用版本3 Compose文件在swarm模式下部署堆栈depends_on时,将忽略该选项 。 2.16 deploy 指定与部署和运行服务相关的配置。 version:"3.7" services: redis: image:redis:alpine deploy: replicas:6 update_config: paralleli...
(随时可用) cpus: "0.2" # 为该容器保留 20% 的 CPU memory: 20M # 为该容器保留 20M 的内存空间 restart_policy # 定义容器重启策略, 用于代替 restart 参数 condition # 定义容器重启策略(接受三个参数) none # 不尝试重启 on-failure # 只有当容器内部应用程序出现问题才会重启 any # 无论如何都会尝试...
condition有三种状态: service_started容器已启动 service_healthy容器处于健康状态 service_completed_successfully容器执行完成且成功退出(退出状态码为0) 重启策略 以下是几种常用的重启策略: no:这是默认值。表示容器停止后不会自动重启。 always:表示容器停止后总是自动重启。
version: '3' services: redis: image: redis:alpine deploy: mode: replicated #global:每个集节点只有一个容器;replicated:指定容器数量(默认) replicas: 6 update_config: delay: 10s order: stop-first parallelism: 2 delay: 10s restart_policy: #容器重启配置,用于替代restart condition: on-failure delay:...
Docker-compose 文件格式的 2.1 版本中有一个名为condition的depends_on选项,可以设置为service_healthy。而且,每个服务都可以有一个healthcheck命令,可以告诉 docker-compose“健康”是什么意思。这在3.0版本中不再可用,也没有提供替换项。 Docker 文档的基本建议是,服务要在其他服务暂时离线的情况下具有弹性,因为这在...
version:'3'services:web:image:nginxdeploy:resources:limits:cpus:'0.50'memory:512Mcpuset:'0-3'memswap_limit:1Greservations:memory:256Mrestart_policy:condition:on-failure 在这个例子中,我们限制了名为web的服务的CPU使用量为50%,内存使用量为512MB,CPU集为0到3,swap内存为1G,并且设置了内存预留为256M。
condition:可选 none,on-failure 或者 any(默认值:any)。 delay:设置多久之后重启(默认值:0)。 max_attempts:尝试重新启动容器的次数,超出次数,则不再尝试(默认值:一直重试)。 window:设置容器重启超时时间(默认值:0)。 rollback_config:配置在更新失败的情况下应如何回滚服务。
services:webfrontend:image:${DOCKER_REGISTRY-}webfrontenddepends_on:mywebapi:condition:service_healthybuild:context:.dockerfile:WebFrontEnd/Dockerfilemywebapi:image:${DOCKER_REGISTRY-}mywebapidepends_on:redis:condition:service_startedhealthcheck:test:curl--failhttp://mywebapi:8080/Counter||exit1interval...