Documentation
¶
Overview ¶
Package stdcopy implements the Docker multiplexed-stream protocol used by the attach, exec and logs endpoints.
The wire format (when Tty=false on the server) is:
+----------+---------+---------+---------+---------+ | 1 byte | 3 bytes | 4 bytes (BE) | | STREAM | padding | FRAME SIZE (uint32, big) | +----------+---------+---------+---------+---------+ | FRAME PAYLOAD (FRAMEsIZE bytes) | +--------------------------------------------------+
STREAM values: 0 = stdin, 1 = stdout, 2 = stderr.
When Tty=true, the server sends raw bytes without framing (the PTY already merges stdout+stderr).
This file is the Go counterpart of github.com/docker/cli/pkg/stdcopy and matches Docker Engine v25+ framing exactly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHeader = errors.New("stdcopy: invalid frame header")
ErrInvalidHeader is returned when the 8-byte header is malformed.
Functions ¶
func StdCopy ¶
StdCopy is the equivalent of github.com/docker/cli/pkg/stdcopy.StdCopy: demultiplexes r into stdout and stderr writers. A non-blocking read of stdout is forwarded to dstOut; stderr to dstErr. Stdin frames on the read side are also forwarded to dstOut (legacy Docker behavior).
Loop terminates cleanly on EOF. Any frame >2 (protocol extension) is silently skipped.
func StdCopySingleReader ¶
StdCopySingleReader is like StdCopy but for the case when the source is an unframed raw stream (Tty=true). It just copies src to dst.
func WriteFrame ¶
WriteFrame writes a single frame to w: 8-byte header + payload.
Types ¶
type StreamType ¶
type StreamType byte
StreamType identifies the channel in a multiplexed frame.
const ( StreamStdin StreamType = 0 StreamStdout StreamType = 1 StreamStderr StreamType = 2 )