Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/container: Fill ConsoleSize in create #3619

Merged
merged 1 commit into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/command/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig
}
}

hostConfig.ConsoleSize[0], hostConfig.ConsoleSize[1] = dockerCli.Out().GetTtySize()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be filled only if config.Tty?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was somewhat looking at that; then again, if I'm not mistaken, that's also gated at the daemon-side (so it only applies the options if there's a TTY), and possibly (need to check) again on the runtime (containerd) side.

The code was already taking this approach, so I didn't consider it a blocker, but we could look into different scenarios (feel free to do so 😃).


response, err := dockerCli.Client().ContainerCreate(ctx, config, hostConfig, networkingConfig, platform, opts.name)
if err != nil {
// Pull image if it does not exist locally and we have the PullImageMissing option. Default behavior.
Expand Down
6 changes: 0 additions & 6 deletions cli/command/container/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func runRun(dockerCli command.Cli, flags *pflag.FlagSet, ropts *runOptions, copt
// nolint: gocyclo
func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptions, containerConfig *containerConfig) error {
config := containerConfig.Config
hostConfig := containerConfig.HostConfig
stdout, stderr := dockerCli.Out(), dockerCli.Err()
client := dockerCli.Client()

Expand All @@ -118,11 +117,6 @@ func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptio
config.StdinOnce = false
}

// Currently ignored on Linux daemons, in the Linux case the TTY size is
// set by calling MonitorTtySize.
// A Windows daemon will create the process with the right TTY size
hostConfig.ConsoleSize[0], hostConfig.ConsoleSize[1] = dockerCli.Out().GetTtySize()

ctx, cancelFun := context.WithCancel(context.Background())
defer cancelFun()

Expand Down