Skip to main content
Replace my-container with the ID or name of an existing container. With follow enabled, wait() keeps consuming output until the stream ends or the underlying client interrupts it. Omit follow to read the currently available logs.

Output chunks and TTY mode

Callbacks receive output chunks, not necessarily complete lines. Buffer chunks in your application if it processes output line by line. Non-TTY output has separate stdout and stderr channels. TTY containers combine both on onStdout. For a response marked application/vnd.docker.raw-stream, the client inspects the container’s TTY setting to distinguish terminal output from framed output. Your daemon credentials need permission to inspect the container. Responses marked application/vnd.docker.multiplexed-stream do not need that extra request.

Read recent output without following

Continue with the $docker client above. This query is finite:
tail is a string, including numeric-looking values; since is an integer for this endpoint. That differs from the string timestamps accepted by systemEvents(). Log availability also depends on the daemon’s logging driver and configuration; this call is not a replacement for a durable logging service.

Process output line by line

Maintain separate buffers for stdout and stderr. For a single channel, a simple bounded line buffer can be registered as a callback:
This handles lines split across chunks and a final line without a newline. It limits the incomplete-line buffer; applications should also cap or stream their total retained output. Use separate buffers if you add onStderr(). Terminal escape sequences are not removed by Docker frame decoding.

Raw response bodies

executeRawEndpoint() and the deprecated FETCH_RESPONSE mode return the raw body. Non-TTY output includes Docker’s binary frame headers in that body. Do not print it directly if you want readable output; use the callback stream. The same distinction applies to exec output.