8 "golang.org/x/net/context"
10 "github.com/docker/docker/api/types"
11 timetypes "github.com/docker/docker/api/types/time"
14 // ContainerLogs returns the logs generated by a container in an io.ReadCloser.
15 // It's up to the caller to close the stream.
16 func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
18 if options.ShowStdout {
19 query.Set("stdout", "1")
22 if options.ShowStderr {
23 query.Set("stderr", "1")
26 if options.Since != "" {
27 ts, err := timetypes.GetTimestamp(options.Since, time.Now())
31 query.Set("since", ts)
34 if options.Timestamps {
35 query.Set("timestamps", "1")
39 query.Set("details", "1")
43 query.Set("follow", "1")
45 query.Set("tail", options.Tail)
47 resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil)