mirror of https://github.com/docker/cli.git
Merge pull request #1472 from lifubang/sshlogs
Enhancement: don't need to type ssh password twice when docker logs with ssh
This commit is contained in:
commit
6b71e84ec8
|
@ -50,6 +50,11 @@ func NewLogsCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
func runLogs(dockerCli command.Cli, opts *logsOptions) error {
|
func runLogs(dockerCli command.Cli, opts *logsOptions) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
c, err := dockerCli.Client().ContainerInspect(ctx, opts.container)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
options := types.ContainerLogsOptions{
|
options := types.ContainerLogsOptions{
|
||||||
ShowStdout: true,
|
ShowStdout: true,
|
||||||
ShowStderr: true,
|
ShowStderr: true,
|
||||||
|
@ -60,17 +65,12 @@ func runLogs(dockerCli command.Cli, opts *logsOptions) error {
|
||||||
Tail: opts.tail,
|
Tail: opts.tail,
|
||||||
Details: opts.details,
|
Details: opts.details,
|
||||||
}
|
}
|
||||||
responseBody, err := dockerCli.Client().ContainerLogs(ctx, opts.container, options)
|
responseBody, err := dockerCli.Client().ContainerLogs(ctx, c.ID, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer responseBody.Close()
|
defer responseBody.Close()
|
||||||
|
|
||||||
c, err := dockerCli.Client().ContainerInspect(ctx, opts.container)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Config.Tty {
|
if c.Config.Tty {
|
||||||
_, err = io.Copy(dockerCli.Out(), responseBody)
|
_, err = io.Copy(dockerCli.Out(), responseBody)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue