在dockerfile里添加健康检查

FROM couchbase:latest

COPY configure-node.sh /opt/couchbase

HEALTHCHECK --interval=5s --timeout=3s CMD curl --fail http://localhost:8091/pools || exit 1

CMD ["/opt/couchbase/configure-node.sh"]

The can be:

–interval=DURATION (default 30s).

–timeout=DURATION (default 30s).

–retries=N (default 3).
–start_period=10s
–retries=3

HEALTHCHECK

同样的也可以对service进行更改

sudo docker service update artifactory_daeartifactory  --health-cmd=" curl --fail http://localhost:8081 || exit 1"  --health-interval=60s --health-timeout=30s --health-retries=3

https://zhuanlan.zhihu.com/p/28911530

https://codeblog.dotsandbrackets.com/docker-health-check/

https://docs.docker.com/engine/reference/commandline/service_update/

关于healthy check的解释

You setup healthchecks the same ways your first link suggests. All those ways will tell docker what command to run, how often to run it, etc.

If you use docker run to start a container, the UI will show unhealthy when healthchecks fail, but docker will do nothing to the container. It’s up to you or some higher level monitoring solution to act on it.

If you use docker service create (or docker stack deploy) to create a Swarm service and that healthcheck fails, it will stop/kill the task (container) and reschedule a new task to replace that replica of the service. During the stop/kill (it tries to gracefully stop it, but kills after 10s like all docker containers), Swarm will stop overlay inbound traffic to that task like it does for all stopping tasks.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值