scū*_*lus 10 docker docker-compose health-check docker-healthcheck
我正在使用 Docker Compose 部署一些服务。我想检查我的容器是否运行正常(请参阅此处的healthcheckDocker Compose 文档)。
让我们考虑以下代码。它工作正常,除非我取消注释最后一行:
\n# docker-compose.yml\n\nversion: "3.8"\n\nservices:\n postgres: # this is just an example, please don\'t focus on that particular image\n image: postgres:15-alpine\n healthcheck:\n test: pg_isready -d my_db -U my_user # again, the command here is not my point, nor the env, feel free to change it\n interval: 60s\n start_period: 30s\n # start_interval: 5s # \xe2\x86\x92 this line is commented because it raises an error! Why?\nRun Code Online (Sandbox Code Playgroud)\nDockerfile 文档的此页面描述了指令中各种设置之间的差异HEALTHCHECK。interval它详细说明了选项和选项之间的区别start-interval。
取消注释最后一行会引发以下异常,但为什么呢?诚然,我没有start_interval在 Docker Compose 文档中看到提到过,只是感觉很直观......
validating /my_path/docker-compose.yml: services.postgres.healthcheck Additional property start_interval is not allowed\nRun Code Online (Sandbox Code Playgroud)\n该start_period选项已添加到文件格式 3.4(发行说明)中。我是否正确地假设start_interval尚未引入且无法由 Docker Compose 解析?我是唯一需要此功能的人吗?
还有其他解决方案吗?我的docker-compose.yml收集了许多我想要的服务healthcheck。我想避免Dockerfile为每个人都有一个:只要有可能,我就依靠环境变量来自定义默认图像,并且我只是将说明放在healthcheck我的docker-compose.yml.
scū*_*lus 11
为未来的读者回答我自己的问题。
这是 Docker Compose 中的一项新功能。几天前它已经实施了。我绝对不是唯一一个因这种缺乏而感到沮丧的人!
这是已合并并发布的相应拉取请求(发行说明compose-go和发行说明docker compose)。
因此,更新我的版本Docker Compose来v2.20.2解决该问题。
| 归档时间: |
|
| 查看次数: |
3080 次 |
| 最近记录: |