Merge pull request #3627 from vvoland/3554-exec-size

command/exec: Fill ConsoleSize
This commit is contained in:
Sebastiaan van Stijn 2022-06-27 17:26:02 +02:00 committed by GitHub
commit 44f3b87f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -117,6 +117,8 @@ func RunExec(dockerCli command.Cli, options ExecOptions) error {
}
}
fillConsoleSize(execConfig, dockerCli)
response, err := client.ContainerExecCreate(ctx, options.Container, *execConfig)
if err != nil {
return err
@ -131,12 +133,20 @@ func RunExec(dockerCli command.Cli, options ExecOptions) error {
execStartCheck := types.ExecStartCheck{
Detach: execConfig.Detach,
Tty: execConfig.Tty,
ConsoleSize: execConfig.ConsoleSize,
}
return client.ContainerExecStart(ctx, execID, execStartCheck)
}
return interactiveExec(ctx, dockerCli, execConfig, execID)
}
func fillConsoleSize(execConfig *types.ExecConfig, dockerCli command.Cli) {
if execConfig.Tty {
height, width := dockerCli.Out().GetTtySize()
execConfig.ConsoleSize = &[2]uint{height, width}
}
}
func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *types.ExecConfig, execID string) error {
// Interactive exec requested.
var (
@ -157,10 +167,12 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *typ
stderr = dockerCli.Err()
}
}
fillConsoleSize(execConfig, dockerCli)
client := dockerCli.Client()
execStartCheck := types.ExecStartCheck{
Tty: execConfig.Tty,
ConsoleSize: execConfig.ConsoleSize,
}
resp, err := client.ContainerExecAttach(ctx, execID, execStartCheck)
if err != nil {