What is the authoritative list of Docker Run exit codes?

时间:2015-07-08 15:49:11

标签: docker exitstatus

Apologies if this has been asked, but nowhere in the Docker documentation can I find an authoritative list of exit codes (also called exit status). Surprising! I see suggestions about making it consistent, but no docs on docker.com.

Does anyone know where the exit codes can be found?

3 个答案:

答案 0 :(得分:50)

对于Docker> = 1.10,请参阅标准this PR后的chroot exit codes

  • 125docker run本身失败
  • 126:无法调用包含的命令
  • 127:如果找不到包含的命令
  • 128 + n致命错误信号n
    • 130 = (128+2)容器由Control-C终止
    • 137 = (128+9)容器收到SIGKILL
    • 143 = (128+15)容器收到SIGTERM

查看signal的手册页以获取完整列表(在cmd类型man signal上或在线查看,例如signal)。

检查Docker documentation以获取有关当前版本的更多信息。

答案 1 :(得分:11)

通常它将是该过程的退出状态,因此它依赖于应用程序,即:

$ docker run debian sh -c "exit 5;"
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
7fcc37778df0        debian              "sh -c 'exit 5;'"   4 seconds ago       Exited (5) 3 seconds ago                       reverent_einstein   

但在某些情况下,Docker本身可以返回退出代码:

  • 125如果Docker守护程序出错(例如提供了错误的标志)
  • 126,如果无法调用容器命令(例如文件不可执行)
  • 127,如果找不到容器命令(例如错误的二进制路径)

https://docs.docker.com/engine/reference/run/#exit-status

答案 2 :(得分:0)

Docker退出代码在official Docker documentation中有详细记录。