How does the health check work in a Swarm?

Suppose the health check for a container fails in a swarm. What happens then?

  • Does Docker stop sending requests to the respective task in the Swarm?
  • Does Docker kill the respective task in the Swarm and create a new one?

If by container you mean a task that is part of a service then yes, docker will fire up new instance depending on how the service is set up. Look into:

--restart-condition string            Restart when condition is met (none, on-failure, or any)
--restart-delay value                 Delay between restart attempts (default none)
--restart-max-attempts value          Maximum number of restarts before giving up (default none)
--restart-window value                Window used to evaluate the restart policy (default none)