Add support for container wait conditions #2487
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Expose the
condition
query parameter (added in Docker Engine API v1.30) onWaitContainerCmd
. When the parameter is omitted, we keep the daemon’s defaultnot-running
behaviour.Practical implications
create → wait (no condition) → start Calling
wait
right aftercreate
but beforestart
returns immediately with whatever exit-code the daemon reports for a container that has never run (typically0
). In other words, you learn nothing about the future process.create → start → wait (no condition) For short-lived containers started with
--rm
, the container may be auto-removed before the client manages to issuewait
, resulting in a "container not found" error.create → wait(condition=removed) → start Passing the new
removed
condition eliminates both races: the wait call blocks until the container has exited and been removed, reliably yielding the actual exit code even for--rm
containers.