Is it possible to restart container in docker-compose if service that is running inside it returns exit code different than 0
? docker-compose.yml option restart: always
doesn't work that way. Is there any way to solve it or is this a service issue and I should look for the answer inside of the container?
I use supervisord but adding option autorestart=true
doesn't work even if service crashes with exit code 255
- the RUNNING_PID
file (created by system) is not being deleted.
Thanks for any reply.
restart: always
will restart the container regardless of the exit code, so even if exit code of the process running inside the container is 0
. I'm using restart: on-failure
and it does exactly what you describe. It restarts the container on a non zero exit code of the process. After the process exits and it is not restarted you can check the exit code using docker-compose ps