@@ -62,6 +62,8 @@ type initConfig struct {
6262 ContainerId string `json:"containerid"`
6363 Rlimits []configs.Rlimit `json:"rlimits"`
6464 CreateConsole bool `json:"create_console"`
65+ ConsoleWidth uint16 `json:"console_width"`
66+ ConsoleHeight uint16 `json:"console_height"`
6567 Rootless bool `json:"rootless"`
6668}
6769
@@ -171,12 +173,25 @@ func setupConsole(socket *os.File, config *initConfig, mount bool) error {
171173 // however, that setupUser (specifically fixStdioPermissions) *will* change
172174 // the UID owner of the console to be the user the process will run as (so
173175 // they can actually control their console).
174- console , slavePath , err := console .NewPty ()
176+
177+ pty , slavePath , err := console .NewPty ()
175178 if err != nil {
176179 return err
177180 }
181+
182+ if config .ConsoleHeight != 0 && config .ConsoleWidth != 0 {
183+ err = pty .Resize (console.WinSize {
184+ Height : config .ConsoleHeight ,
185+ Width : config .ConsoleWidth ,
186+ })
187+
188+ if err != nil {
189+ return err
190+ }
191+ }
192+
178193 // After we return from here, we don't need the console anymore.
179- defer console .Close ()
194+ defer pty .Close ()
180195
181196 // Mount the console inside our rootfs.
182197 if mount {
@@ -185,7 +200,7 @@ func setupConsole(socket *os.File, config *initConfig, mount bool) error {
185200 }
186201 }
187202 // While we can access console.master, using the API is a good idea.
188- if err := utils .SendFd (socket , console .Name (), console .Fd ()); err != nil {
203+ if err := utils .SendFd (socket , pty .Name (), pty .Fd ()); err != nil {
189204 return err
190205 }
191206 // Now, dup over all the things.
0 commit comments