11

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.

Gergely Toth
  • 6,638
  • 2
  • 38
  • 40
Thomas
  • 741
  • 4
  • 9
  • 20

1 Answers1

15

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

Gergely Toth
  • 6,638
  • 2
  • 38
  • 40
  • Thanks for reply, but my case is a little different - even if service exits with code different than 0, the container doesn't show it (it's still marked as Up in docker-compose ps). – Thomas Jul 15 '16 at 07:17