Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

ContainerLogs with default ContainerLogsOption #345

@htfy96

Description

@htfy96

I copied

func ExampleClient_ContainerLogs_withTimeout() {
    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
    defer cancel()

    client, _ := NewEnvClient()
    reader, err := client.ContainerLogs(ctx, "container_id", types.ContainerLogsOptions{})
    if err != nil {
        log.Fatal(err)
    }

    _, err = io.Copy(os.Stdout, reader)
    if err != nil && err != io.EOF {
        log.Fatal(err)
    }
}

from the example at container_logs_test.go, but the server raised an error Error response from daemon: Bad parameters: you must choose at least one stream.

Then I changed types.ContainerLogsOptions{} with types.ContainerLogsOptions{ShowStdout: true} and everything worked well.

So I was wondering whether this example could be misleading for beginners, or is there anything that I didn't notice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions