【发布时间】:2019-09-06 01:42:02
【问题描述】:
我有以下docker-compose 文件
version: "3.7"
services:
myservice:
restart: always
image: myimage
hostname: myhost
env_file:
- ./env/common.env
healthcheck:
test: ["CMD-SHELL", "curl --silent --fail localhost:9091/status || exit 1"]
interval: 5s
timeout: 1s
retries: 1
start_period: 5s
ports:
- 27018:27018
volumes:
- type: bind
source: ./scripts/myservice
target: /scripts
entrypoint: ["/bin/sh", "-c", "apk add bash && chmod a+x /scripts/init.sh && /scripts/init.sh"]
在运行docker-compose run myservice 时,我的容器正确启动(它不会崩溃)。
但是,健康检查失败,当我执行docker ps 时,我可以看到容器不健康。
我希望容器在容器运行状况不佳时自动重新启动,但是容器会在日志中引发错误并在进行 curl 调用时继续运行。
如何确保我的容器在运行状况检查失败时重新启动?
【问题讨论】:
标签: docker docker-compose health-monitoring