Skip to main content
Glama

container_wait

Read-only

Block until a Docker container reaches a condition: stopped, healthy, or a log pattern appears. Returns met and timed_out flags, never raises on timeout.

Instructions

Block until a container reaches a condition: stopped, "healthy", or its logs contain a pattern.

One contract for every mode: never raises on timeout — the result always carries met (condition reached) and timed_out. The stop conditions ("not-running"/"next-exit"/"removed") use the daemon's blocking wait and fill status_code/error (the container's exit info); "healthy" polls the container's HEALTHCHECK every poll_intervals and fills health/status; "log-match" polls recent logs every poll_intervals for pattern and fills matched_line. For a compose project use compose_wait; for swarm services use service_wait.

Health semantics: with no HEALTHCHECK defined, once the container is running the tool returns promptly with health: null and met: false (false = "not confirmed healthy", not "unhealthy" — check health to tell them apart). A container that exits before becoming healthy returns its terminal status and met: false.

Log-match semantics: pattern is matched as a plain substring by default — safe against any input, including adversarial ones. Pass regex=True to match pattern as a regular expression (via re.search) instead; only do this with patterns you trust, since a regex with catastrophic backtracking run against attacker-influenced log content can exhaust CPU (ReDoS). Checks stdout and stderr, most recent lines first within each poll. If the container exits/dies before the pattern ever appears, returns promptly with met=false (not timed_out) — no further logs can arrive, so there's nothing to keep polling for.

args: id_or_name - The container id or name until - Condition to wait for: "not-running" (default), "next-exit", "removed", "healthy", or "log-match" (requires pattern) timeout_seconds - Max seconds to wait before returning with timed_out=true (default 600) poll_interval - "healthy"/"log-match" only: seconds between re-checks (default 2, > 0); capped by the time left so a large value can't push the total wait past the timeout pattern - "log-match" only: substring (or, with regex=True, a regular expression) to look for in the container's logs regex - "log-match" only: treat pattern as a regular expression instead of a plain substring returns: dict - {"container", "until", "met", "timed_out", "status_code", "error", "health", "status", "matched_line", "waited_seconds"}; stop modes fill status_code/error, "healthy" fills health ("starting"/"healthy"/"unhealthy", or null with no healthcheck) and status, "log-match" fills matched_line when met and status if the container exited without matching.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regexNo
untilNonot-running
patternNo
id_or_nameYes
poll_intervalNo
timeout_secondsNo
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations (readOnlyHint, destructiveHint), the description discloses critical behaviors: never raises on timeout, result always carries met/timed_out; health semantics with no HEALTHCHECK returning met:false and health:null; log-match matching as plain substring unless regex=True, plus a ReDoS warning; and exit-before-match returning promptly with met=false. This is rich, non-obvious context that annotations don't cover.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but tightly structured into intro, contract, mode semantics, health semantics, log-match semantics, and args. Every sentence adds meaningful behavioral or usage detail; there is no filler, redundancy, or verbosity. It earns its length through density of useful information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description explains the return dict and which fields each mode populates. It covers edge cases: no HEALTHCHECK definition, container exits before pattern appears, regex catastrophic backtracking, and timeout behavior. For a tool with 6 parameters and no output schema, this is complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It does so thoroughly: id_or_name, until with valid enum values, timeout_seconds default 600, poll_interval default 2 with >0 constraint and capping, pattern required for log-match, regex boolean. It also notes mode-specific return fields per parameter, fully compensating for the schema's silence.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description opens with 'Block until a container reaches a condition: stopped, "healthy", or its logs contain a pattern.' This is a specific verb+resource+outcome statement that clearly defines the tool's function. It also distinguishes from siblings by name-checking compose_wait and service_wait for other orchestrations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use alternatives: 'For a compose project use compose_wait; for swarm services use service_wait.' It further explains the different modes (not-running, healthy, log-match) and when each is appropriate, providing clear context and exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/L337-org/docker-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server