-
Notifications
You must be signed in to change notification settings - Fork 18.8k
docs(client/ContainerExecAttach): add a mention to stdcopy.StdCopy #50119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(client/ContainerExecAttach): add a mention to stdcopy.StdCopy #50119
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
client/container_exec.go
Outdated
// The Reader contained in the hijacked connection should be read using | ||
// the stdcopy.StdCopy function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly (to make things even less intuitive) this is only true if the container was created with Tty = false
.
Not 100% sure, so needs double checking 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this way, I'll add an additional comment later today. Thanks for the catch ! :)
moby/api/server/router/container/exec.go
Lines 130 to 135 in 829b695
if options.Tty { | |
stdout = outStream | |
} else { | |
stderr = stdcopy.NewStdWriter(outStream, stdcopy.Stderr) | |
stdout = stdcopy.NewStdWriter(outStream, stdcopy.Stdout) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we have a similar doc on the ContainerAttach
function:
moby/client/container_attach.go
Lines 12 to 36 in b6669f1
// ContainerAttach attaches a connection to a container in the server. | |
// It returns a types.HijackedConnection with the hijacked connection | |
// and the a reader to get output. It's up to the called to close | |
// the hijacked connection by calling types.HijackedResponse.Close. | |
// | |
// The stream format on the response will be in one of two formats: | |
// | |
// If the container is using a TTY, there is only a single stream (stdout), and | |
// data is copied directly from the container output stream, no extra | |
// multiplexing or headers. | |
// | |
// If the container is *not* using a TTY, streams for stdout and stderr are | |
// multiplexed. | |
// The format of the multiplexed stream is as follows: | |
// | |
// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT} | |
// | |
// STREAM_TYPE can be 1 for stdout and 2 for stderr | |
// | |
// SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian. | |
// This is the size of OUTPUT. | |
// | |
// You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this | |
// stream. | |
func (cli *Client) ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) { |
I think we could partially reuse it here too (but spare the technical details and link to ContainerAttach
for more details).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vvoland Hey ! Sorry it took me a while to copy those few lines. :p This should be good, I copied the non-technical part of the documentation of ContainerExec
and added a reference to it in the documentation for those who'd like to dwelve deeper in the technical details.
7528df3
to
f65407d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
One last step: could you please rebase your branch on top of master
and then squash your commits into one?
d71b6cc
to
0de362a
Compare
Sorry, took me a while, this should be good now :) |
Add a mention to stdcopy.StdCopy to the documentation, as the stream returned in the HijackedResponse is multiplexed when tty is disabled. Signed-off-by: Medhy DOHOU <52136144+PowerPixel@users.noreply.github.com>
0de362a
to
4891396
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Add a mention to stdcopy.StdCopy to the documentation, as the stream returned in the HijackedResponse is multiplexed.
Closes #50118
- What I did
I added a mention to
stdcopy.StdCopy
to the documentation of theclient.ContainerExecAttach
method.- How I did it
I simply added a few lines of documentation under the existing one for the
client.ContainerExecAttach
method.- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)