Docker Automatic Restart Policy
The Docker container can detect that PID 1 (main process) has stopped and will automatically restart the container if ‘docker run –restart=always’ is enabled. However, there are some signals not honored if the PID was killed using certain signals. Here is some data based on testing, as a reference:
This list applies to both Mac (running Docker-Machine) and Linux (all flavors). Tested on Docker v1
Signal ID |
Signal Type |
Triggers container restart? |
1 (HUP) |
Hangup |
Yes |
2 (INT) |
Interrupt |
Yes |
3 (QUIT) |
Quit |
No |
4 (ABRT) |
Abort |
Yes |
9 (KILL) |
Kill |
No |
14 (ALRM) |
Alarm |
No |
15 (TERM) |
Terminate |
Yes |