Skip to content

Commit

Permalink
Merge pull request #1472 from lifubang/sshlogs
Browse files Browse the repository at this point in the history
Enhancement: don't need to type ssh password twice when docker logs with ssh
  • Loading branch information
silvin-lubecki authored Oct 26, 2018
2 parents 0904fbf + aba8821 commit 6b71e84
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cli/command/container/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func NewLogsCommand(dockerCli command.Cli) *cobra.Command {
func runLogs(dockerCli command.Cli, opts *logsOptions) error {
ctx := context.Background()

c, err := dockerCli.Client().ContainerInspect(ctx, opts.container)
if err != nil {
return err
}

options := types.ContainerLogsOptions{
ShowStdout: true,
ShowStderr: true,
Expand All @@ -60,17 +65,12 @@ func runLogs(dockerCli command.Cli, opts *logsOptions) error {
Tail: opts.tail,
Details: opts.details,
}
responseBody, err := dockerCli.Client().ContainerLogs(ctx, opts.container, options)
responseBody, err := dockerCli.Client().ContainerLogs(ctx, c.ID, options)
if err != nil {
return err
}
defer responseBody.Close()

c, err := dockerCli.Client().ContainerInspect(ctx, opts.container)
if err != nil {
return err
}

if c.Config.Tty {
_, err = io.Copy(dockerCli.Out(), responseBody)
} else {
Expand Down

0 comments on commit 6b71e84

Please sign in to comment.