📜  docker healthcheck - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:27.956000             🧑  作者: Mango

代码示例1
version: "3.8"
services:
  image: "node:14-alpine" 
  healthcheck: 
    interval: 120s
    retries: 5
    start_period: 60s
    test: |
        touch healthcheck.txt &&
        mkdir healthcheck && 
        mv healthcheck.txt healthcheck &&
        cd healthcheck &&
        echo "hello my docker container is working fine" >> healthcheck.txt && 
        cat healthcheck.txt &&
        sleep 5 &&
        rm "${PWD}/healthcheck.txt" &&
        cd .. &&
        sleep 5 &&
        rmdir "${PWD}/healthcheck" &&
        exit 0
    timeout: 30s