(ctx context.Context, dockerCli command.Cli, opts *logsOptions)
| 54 | } |
| 55 | |
| 56 | func runLogs(ctx context.Context, dockerCli command.Cli, opts *logsOptions) error { |
| 57 | c, err := dockerCli.Client().ContainerInspect(ctx, opts.container, client.ContainerInspectOptions{}) |
| 58 | if err != nil { |
| 59 | return err |
| 60 | } |
| 61 | |
| 62 | resp, err := dockerCli.Client().ContainerLogs(ctx, c.Container.ID, client.ContainerLogsOptions{ |
| 63 | ShowStdout: true, |
| 64 | ShowStderr: true, |
| 65 | Since: opts.since, |
| 66 | Until: opts.until, |
| 67 | Timestamps: opts.timestamps, |
| 68 | Follow: opts.follow, |
| 69 | Tail: opts.tail, |
| 70 | Details: opts.details, |
| 71 | }) |
| 72 | if err != nil { |
| 73 | return err |
| 74 | } |
| 75 | defer func() { _ = resp.Close() }() |
| 76 | |
| 77 | if c.Container.Config.Tty { |
| 78 | _, err = io.Copy(dockerCli.Out(), resp) |
| 79 | } else { |
| 80 | _, err = stdcopy.StdCopy(dockerCli.Out(), dockerCli.Err(), resp) |
| 81 | } |
| 82 | return err |
| 83 | } |
searching dependent graphs…