Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

ContainerLogs with default ContainerLogsOption #345

Open
htfy96 opened this issue Aug 1, 2016 · 1 comment
Open

ContainerLogs with default ContainerLogsOption #345

htfy96 opened this issue Aug 1, 2016 · 1 comment

Comments

@htfy96
Copy link

htfy96 commented Aug 1, 2016

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?

@zsluedem
Copy link

as the error said, you have to choose one stream either stdout or stderr. If you don't input any of these option to be true, it would panic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants