Docker-compose restart container if service is dead

Is it possible to restart the container in docker layout if the service running inside it returns an exit code other than 0 ? the docker-compose.yml restart: always option does not work. Is there a way to solve the problem or is it a service problem and should I look for an answer inside the container?

I use supervisord, but adding the autorestart=true option does not work, even if the service fails with exit code 255 , the RUNNING_PID file (created by the system) is not deleted.

Thanks for any answer.

+5
source share
1 answer

'restart: always' will restart the container regardless of the exit code, so even if the exit code for the process running inside the container is '0'. I use "restart: on-failure" and it does exactly what you describe. It restarts a container with a non-zero process termination code. After completing the process and restarting it, you can check the exit code using the docker-compose ps command

+3
source

All Articles