参考文章 https://betterprogramming.pub/understanding-docker-container-exit-codes-5ee79a1d58f6
Exit Codes
Common exit codes associated with docker containers are:
Exit Code 0: Absence of an attached foreground process 前台程序进程结束
Exit Code 1: Indicates failure due to application error 应用报错
Exit Code 137: Indicates failure as container received SIGKILL (Manual intervention or ‘oom-killer’ [OUT-OF-MEMORY]) 被手动干预杀死进程,或者违反系统限制被杀
Exit Code 139: Indicates failure as container received SIGSEGV
Exit Code 143: Indicates failure as container received SIGTERM
举例,
01 (Exit Codes 0)
docker run hello-world
进程结束,exit code为0
02 (Exit Codes 1)
程序自身崩溃报错,或者人工把dockerfile中的启动命令写错,都会报exit code 1
03(Exit Codes 137)
程序收到了SIGKILL (signal kill)信号,被手动干预杀死进程,或者违反系统限制被杀 都会报错 exit code 137
04 (Exit Codes 139)
程序 segmentation fault,程序试图访问不被允许访问的内存地址,可能是程序代码或者是基础镜像的错误,可能报错 exit code 139
05 (Exit Codes 143)
容器收到了 SIGTERM 指令,也就是停止的指令,例如docker stop