作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
从docker-compose 1.10.0 there is support for health checks开始。我开始在我的docker-compose文件之一中实现这些功能。
有几个建议从docker ps
查看容器健康状态的站点。见下文。
但是,运行docker ps
时我看不到任何健康状况。我的docker-compose文件的摘录如下:
version: "2.1"
services:
my-service:
container_name: my-service
image: "our-registry:5000/my-service:1.0.1"
expose: [3000]
restart: always
depends_on:
- other-service-1
- other-service-2
healthcheck:
test: ["nc", "-z", "127.0.0.1", "3000", "||", "exit", "1"]
interval: "2s"
timeout: "1
docker ps
输出的摘录如下:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
af680b9fc6c3 our-registry/pr-georegion:1.0.1 "node index.js" 8 minutes ago Up 8 minutes 3000/tcp pr-georegion
# docker -v
Docker version 1.12.6, build 78d1802
# docker-compose -v
docker-compose version 1.10.1, build b252738
最佳答案
我在docker-compose文件中发现了问题。来自[官方文档](测试必须为字符串或列表。如果为列表,则第一项必须为NONE,CMD或CMD-SHELL。如果为字符串,则等效于指定CMD-SHELL后跟该字符串。):
test must be either a string or a list. If it’s a list, the first item must be either NONE, CMD or CMD-SHELL. If it’s a string, it’s equivalent to specifying CMD-SHELL followed by that string.
test: ["nc", "-z", "127.0.0.1", "3000", "||", "exit", "1"]
test: ["CMD-SHELL", "nc -z 127.0.0.1 3000 || exit 1"]
关于docker - 如何从docker-compose文件中查看容器的容器健康状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42023837/
我是一名优秀的程序员,十分优秀!