Search CTRL + K

Exit Code

退出状态码(Exit Code) 是 Linux 中进程退出的原因指引。状态码在 0~255 之间,0 表示正常退出;状态码在 1~128 之间表示程序因为自身原因退出;状态码区间为 129 - 255 表示因外界中断导致程序退出。

常见的 退出状态码 如下所示 [1]

Code Name What it means
Exit Code 0 Purposely stopped Used by developers to indicate that the container was automatically stopped
Exit Code 1 Application error Container was stopped due to application error or incorrect reference in the image specification
Exit Code 125 Container failed to run error The docker run command did not execute successfully
Exit Code 126 Command invoke error A command specified in the image specification could not be invoked
Exit Code 127 File or directory not found File or directory specified in the image specification was not found
Exit Code 128 Invalid argument used on exit Exit was triggered with an invalid exit code (valid codes are integers between 0-255)
Exit Code 134 Abnormal termination (SIGABRT) The container aborted itself using the abort() function.
Exit Code 137 Immediate termination (SIGKILL) Container was immediately terminated by the operating system via SIGKILL signal
Exit Code 139 Segmentation fault (SIGSEGV) Container attempted to access memory that was not assigned to it and was terminated
Exit Code 143 Graceful termination (SIGTERM) Container received warning that it was about to be terminated, then terminated
Exit Code 255 Exit Status Out Of Range Container exited, returning an exit code outside the acceptable range, meaning the cause of the error is not known

如果 退出状态码 大于等于 128,表示进程被接收到的信号杀死,退出状态码 减去 128 就是信号值。比如 退出状态码 为 137 表示收到 SIGKILL(信号值为 9)。

可以通过 Linux Man Page 查看所有的信号值。

What are Container Exit Codes

Exit codes are used by container engines, when a container terminates, to report why it was terminated.[1:1]

  1. ↩︎ ↩︎