HEALTHCHECK: Dockerfile vs docker-compose.yml

Viewed 4948

We are deploying our services using a Docker Compose file and Docker Swarm. I was wondering if there is any difference between putting the healthcheck inside the Dockerfile or if it is better to put it in the docker-compose.yml.

I feel like I've read through all available documentation, but couldn't find anything.

docker-compose.yml

healthcheck:
    test: ["CMD", "curl", "-f", "http://localhost:8081/ping"]
    interval: 30s
    timeout: 10s

Dockerfile

HEALTHCHECK --interval=30s --timeout=10s CMD curl -f http://localhost:8081/ping
1 Answers
Related