Skip to content

Commit

Permalink
command/exec: Fill ConsoleSize
Browse files Browse the repository at this point in the history
This makes the exec'd process console dimensions immediately match the
users terminal.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
  • Loading branch information
vvoland committed May 20, 2022
1 parent 098a5d0 commit c001d03
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cli/command/container/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions"
apiclient "github.com/docker/docker/client"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -117,6 +118,14 @@ func RunExec(dockerCli command.Cli, options ExecOptions) error {
}
}

if execConfig.Tty {
// ConsoleSize is not supported before API 1.42
if versions.GreaterThanOrEqualTo(client.ClientVersion(), "1.42") {
height, width := dockerCli.Out().GetTtySize()
execConfig.ConsoleSize = &[2]uint{height, width}
}
}

response, err := client.ContainerExecCreate(ctx, options.Container, *execConfig)
if err != nil {
return err
Expand Down

0 comments on commit c001d03

Please sign in to comment.