Signed-off-by: Chun Chen <chenchun.feed@gmail.com>
| ... | ... |
@@ -207,8 +207,8 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err |
| 207 | 207 |
|
| 208 | 208 |
if container.IsRunning() {
|
| 209 | 209 |
logrus.Debugf("killing old running container %s", container.ID)
|
| 210 |
- |
|
| 211 |
- container.SetStopped(&execdriver.ExitStatus{ExitCode: 0})
|
|
| 210 |
+ // Set exit code to 128 + SIGKILL (9) to properly represent unsuccessful exit |
|
| 211 |
+ container.SetStopped(&execdriver.ExitStatus{ExitCode: 137})
|
|
| 212 | 212 |
|
| 213 | 213 |
// use the current driver and ensure that the container is dead x.x |
| 214 | 214 |
cmd := &execdriver.Command{
|
| ... | ... |
@@ -1845,6 +1845,21 @@ The currently supported filters are: |
| 1845 | 1845 |
|
| 1846 | 1846 |
This shows all the containers that have exited with status of '0' |
| 1847 | 1847 |
|
| 1848 |
+##### Killed containers |
|
| 1849 |
+ |
|
| 1850 |
+You can use a filter to locate containers that exited with status of `137` meaning a `SIGKILL(9)` killed them. |
|
| 1851 |
+ |
|
| 1852 |
+ $ docker ps -a --filter 'exited=137' |
|
| 1853 |
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 1854 |
+ b3e1c0ed5bfe ubuntu:latest "sleep 1000" 12 seconds ago Exited (137) 5 seconds ago grave_kowalevski |
|
| 1855 |
+ a2eb5558d669 redis:latest "/entrypoint.sh redi 2 hours ago Exited (137) 2 hours ago sharp_lalande |
|
| 1856 |
+ |
|
| 1857 |
+Any of these events a result in `137` status: |
|
| 1858 |
+ |
|
| 1859 |
+* the `init` process of the container is killed manually |
|
| 1860 |
+* `docker kill` kills the container |
|
| 1861 |
+* Docker daemon restarts which kills all old running containers |
|
| 1862 |
+ |
|
| 1848 | 1863 |
## pull |
| 1849 | 1864 |
|
| 1850 | 1865 |
Usage: docker pull [OPTIONS] NAME[:TAG] | [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG] |