Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of docker-compose exit code?

For example, if I force a container to stop with kill, then docker-compose ps to check my containers, I get State as Exit 137. And with docker-compose stop I get Exit 1/Exit 0

As there are no documentation for exit code, can anyone please explain to me the meaning of it?

like image 425
itsjef Avatar asked Mar 07 '16 18:03

itsjef


People also ask

What is docker 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])

What is docker exit code 127?

Exit Code 127 means a command specified in the container specification refers to a non-existent file or directory. What to do if a container terminated with Exit Code 127? Same as Exit Code 126, identify the failing command and make sure you reference a valid filename and file path available within the container image.

Does Docker compose exit?

The docker compose up command aggregates the output of each container (like docker compose logs --follow does). When the command exits, all containers are stopped. Running docker compose up --detach starts the containers in the background and leaves them running.

What does exited with code 1 mean?

The "Exit Code 1" is simply a "Generic Exit Code" which means the job failed and this can be for any reason.


2 Answers

This has not so much to do with docker as with the system it is running on. If you take a look in this table of reserved exit codes for bash, you can see the line:

128+n   Fatal error signal "n"  kill -9 $PPID of script $? returns 137 (128 + 9)

Which corresponds to the 137 you mention. It is 128 + 9 (SIGKILL), which you can see in the signal(7) man page. Normally a 0 means a clean exit and 1 there was something wrong, these two can suffice for a programmer. They can however range from 1-255, including the reserved ones mentioned above.

This is just a short answer as I am not an expert on the subject, you can find more on this unix.stackexchange thread on default exit code when process is terminated or perhaps someone here can give a much more elaborate answer than mine.

like image 173
Francesco de Guytenaere Avatar answered Nov 02 '22 11:11

Francesco de Guytenaere


It seems you might be running out of memory. It's a Linux standard as mentioned here: http://tldp.org/LDP/abs/html/exitcodes.html


Error Code 128 : Invalid argument to exit


Error Code 128+n : Fatal error signal "n" kill -9 $PPID of script $? returns 137 (128 + 9)


Error 137 in Docker denotes that the container was ‘KILL’ed by ‘oom-killer’ (Out of Memory). This happens when there isn’t enough memory in the container for running the process.

‘OOM killer’ is a proactive process that jumps in to save the system when its memory level goes too low, by killing the resource-abusive processes to free up memory for the system.

Here's a little more info

like image 40
wcyn Avatar answered Nov 02 '22 12:11

wcyn