title: HEALTHCHECK: Dockerfile vs docker-compose.yml
body: <p>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.</p>
  
  <p><em>I feel like I've read through all available documentation, but couldn't find anything.</em></p>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8081/ping"]
      interval: 30s
      timeout: 10s
  </code></pre>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>HEALTHCHECK --interval=30s --timeout=10s CMD curl -f http://localhost:8081/ping
  </code></pre>