Reputation: 13987
I have a docker-compose file that creates 3 Node-js containers and an Nginx container as a forward proxy to load balance.
How can I monitor and restart the Node-js containers when and if they fail?
Traditional wisdom states all containers should only have a single proccess. So running systemd (or similar) on the node containers would break that pattern.
__--== UPDATE ==--__
As @mishunika stated below, if the node process fails with a correct exit code and there are correct restart policies on the container, it will restart.
Upvotes: 1
Views: 937
Reputation: 1916
First of all, it really depends in what circumstances a node.js container may fail, and if it does so, the container should probably stop and return an exit status code.
As of docker 1.2, there are so-called restart policies. I suppose that a failing node instance may stop the container and return a non-zero. In that case you can specify the on-failure policy at the container level.
In compose you can specify it by:
container_name:
build: .
...
restart: on-failure
Upvotes: 1