New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker run exit code consisency #6734
Comments
|
This is especially important for automation, where it often key to know if a problem happened w/in the container or within docker. Scraping output/logs is frequently not good enough, since not all error messages have the word "error" in them 😖 There really are not many better ways to do this than reserve some range of exit codes for docker, unlikely to clash with the majority of contained-processes. For the minority that may clash, they can be wrapped/mapped onto other numbers. Using the cheroot-convention, or something similar strikes me as a really helpful change. |
|
@rhatdan's suggestion is a good one, consistent with reserved shell exit code guidelines: However, we needn't try to cram all termination/failure reasons into the user exit code space. The API (and docker inspect) could provide another field or fields with more detail regarding system errors and/or even client-defined termination reasons, for clients that care. Numerous things could go wrong when creating and setting up a container or starting the application. Or the container could exceed its memory limit. Or the host could run out of memory. Or looking beyond factors under Docker's control, Docker could crash, the host could crash or reboot, containers could fail liveness probes (e.g., systemd watchdog), or the user or higher-level system could stop the container for a variety of reasons. See also: |
|
@bgrant0607 Why don't we use the API to provide very detailed error data (what caused it and error strings, etc) but get the |
|
Am I understanding right, it would look something like (exact numeric codes not important to me): 125 Docker CLI itself fails, no other data available except printed error message.
|
|
Unless we can get more specific. Like the 125 Docker CLI itself fails, no other data available except printed error message.
|
|
@cevich Basically, yes. Exit codes provide "classes" of error types and the actual output to |
|
@cyphar Telling the user what the failure cause was is necessary but not sufficient. Systems will make decisions based on the cause of the failure, such as whether to restart the container on the same or on a different host, or whether to increase its memory limit. Querying the API for more info in the case of a failure is acceptable. |
|
@crosbymichael @tianon |
|
@duglin If you are going to do my suggested solution, I am all for it. |
|
That's my plan - just want to make sure one of the core maintainers is ok with the direction first. |
|
+1, this would be extremely useful |
|
@duglin Have you made any progress, or I can get one of my engineers to work on this. |
|
I was waiting for the official "+1" from a maintainer but if one of your guys wants to jump on it, go for it. |
|
@duglin was returning error messages in the headers part of the work to support a change like this? |
|
@crosbymichael Nope that's not related to this at all. |
|
status on this anyone? |
|
We have not worked on it. But I can raise it's priority. |
|
@rhatdan let me know when you do start it - its still on my todo list too.... |
|
+1 this would be a nice improvement for integration |
|
Upon reviewing this again, I think the best method would be to have the exit code for the |
|
We have started working on this again, basically looking at returning 127 most of the time when a docker run/exec/start fails as opposed to a command failing within the container. Once we have this, we could look at trying to see if we can figure out 126 errors where we could not find the PID 1 command. |
|
@rhatdan What happens if the |
|
Just for reference/ideas, there's plenty of existing implementations that one could draw inspiration from. Quoting the man page EXIT STATUS sections of some Linux/BSD commands: xargsparallelsudosh |
|
@cyphar Yes that is a problem, but as shown above multiple tools that exec other tools have followed this standard and they have the same problem. The main goal is to scripting tools/testing tools to easily tell the difference between the tool failing and the command failing. |
|
there's a PR for this now #14012 |
|
I am still getting "exit status 126" issue, did anybody figured it out? |
|
I got this "exit status 126" because I was mounting a volume and overriding the script that was the entrypoint. I moved the script outside of the directory and it worked. Hope that helps. |
I found other issues that talked about this but I did not find one that addressed it exactly.
The problem is differentiating between an exit code from
docker run blowing up versus the command being run by docker run blowing up.
We could follow the chroot standard.
Exit status:
The text was updated successfully, but these errors were encountered: