engine-api
engine-api copied to clipboard
ContainerLogs with default ContainerLogsOption
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?
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.