Skip to content

fix(docs): use io.Copy in the get logs example#165

Merged
mdelapenya merged 1 commit into
docker:mainfrom
KatIsCoding:fix/readme-logs-example
Jun 22, 2026
Merged

fix(docs): use io.Copy in the get logs example#165
mdelapenya merged 1 commit into
docker:mainfrom
KatIsCoding:fix/readme-logs-example

Conversation

@KatIsCoding

@KatIsCoding KatIsCoding commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Closes: #160

Problem

The "get logs" example in the README copied the log stream using stdcopy.StdCopy(os.Stdout, os.Stderr, logs), pulling in github.com/docker/docker/pkg/stdcopy. Readers following the example would either see garbled output or need an extra dependency that the SDK does not actually require for consuming ctr.Logs().

Root Cause

stdcopy.StdCopy decodes Docker's multiplexed stream format (an 8-byte header per frame carrying the stream type and payload length). The reader returned by ctr.Logs() is not in that multiplexed format, so feeding it to stdcopy.StdCopy results in an error, or no output if not handling the error.

Fix

  • README.md: replace the github.com/docker/docker/pkg/stdcopy import with the standard library io package, and copy the logs with io.Copy(os.Stdout, logs).

Testing

  • Documentation-only change; no tests affected. The updated example compiles and prints the container log output as expected.

@mdelapenya mdelapenya self-assigned this Jun 22, 2026
@mdelapenya mdelapenya added the documentation Improvements or additions to documentation label Jun 22, 2026

@mdelapenya mdelapenya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mdelapenya mdelapenya merged commit 0609481 into docker:main Jun 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

container.Logs are empty

2 participants