Skip to content

Commit 48829dd

Browse files
committed
Add stream format details for attach/logs endpoint
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
1 parent d7c1257 commit 48829dd

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

client/container_attach.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@ import (
1111
// It returns a types.HijackedConnection with the hijacked connection
1212
// and the a reader to get output. It's up to the called to close
1313
// the hijacked connection by calling types.HijackedResponse.Close.
14+
//
15+
// The stream format on the response will be in one of two formats:
16+
//
17+
// If the container is using a TTY, there is only a single stream (stdout), and
18+
// data is copied directly from the container output stream, no extra
19+
// multiplexing or headers.
20+
//
21+
// If the container is *not* using a TTY, streams for stdout and stderr are
22+
// multiplexed.
23+
// The format of the multiplexed stream is as follows:
24+
//
25+
// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
26+
//
27+
// STREAM_TYPE can be 1 for stdout and 2 for stderr
28+
//
29+
// SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian.
30+
// This is the size of OUTPUT.
31+
//
32+
// You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this
33+
// stream.
1434
func (cli *Client) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) {
1535
query := url.Values{}
1636
if options.Stream {

client/container_logs.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ import (
1313

1414
// ContainerLogs returns the logs generated by a container in an io.ReadCloser.
1515
// It's up to the caller to close the stream.
16+
//
17+
// The stream format on the response will be in one of two formats:
18+
//
19+
// If the container is using a TTY, there is only a single stream (stdout), and
20+
// data is copied directly from the container output stream, no extra
21+
// multiplexing or headers.
22+
//
23+
// If the container is *not* using a TTY, streams for stdout and stderr are
24+
// multiplexed.
25+
// The format of the multiplexed stream is as follows:
26+
//
27+
// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
28+
//
29+
// STREAM_TYPE can be 1 for stdout and 2 for stderr
30+
//
31+
// SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian.
32+
// This is the size of OUTPUT.
33+
//
34+
// You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this
35+
// stream.
1636
func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
1737
query := url.Values{}
1838
if options.ShowStdout {

0 commit comments

Comments
 (0)