2014-07-31 16:53:22 -04:00
|
|
|
package daemon
|
|
|
|
|
2016-01-07 17:14:05 -05:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
derr "github.com/docker/docker/errors"
|
|
|
|
)
|
2015-11-05 16:40:42 -05:00
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// ContainerResize changes the size of the TTY of the process running
|
|
|
|
// in the container with the given name to the given height and width.
|
2015-09-29 13:51:40 -04:00
|
|
|
func (daemon *Daemon) ContainerResize(name string, height, width int) error {
|
2015-12-11 12:39:28 -05:00
|
|
|
container, err := daemon.GetContainer(name)
|
2014-09-15 18:56:47 -04:00
|
|
|
if err != nil {
|
2015-03-25 03:44:12 -04:00
|
|
|
return err
|
2014-09-15 18:56:47 -04:00
|
|
|
}
|
2015-05-01 21:03:35 -04:00
|
|
|
|
2015-11-05 16:40:42 -05:00
|
|
|
if !container.IsRunning() {
|
|
|
|
return derr.ErrorCodeNotRunning.WithArgs(container.ID)
|
|
|
|
}
|
|
|
|
|
2015-11-03 12:33:13 -05:00
|
|
|
if err = container.Resize(height, width); err == nil {
|
2016-01-07 17:14:05 -05:00
|
|
|
attributes := map[string]string{
|
|
|
|
"height": fmt.Sprintf("%d", height),
|
|
|
|
"width": fmt.Sprintf("%d", width),
|
|
|
|
}
|
|
|
|
daemon.LogContainerEventWithAttributes(container, "resize", attributes)
|
2015-11-03 12:33:13 -05:00
|
|
|
}
|
|
|
|
return err
|
2015-05-01 21:03:35 -04:00
|
|
|
}
|
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// ContainerExecResize changes the size of the TTY of the process
|
|
|
|
// running in the exec with the given name to the given height and
|
|
|
|
// width.
|
2015-09-29 13:51:40 -04:00
|
|
|
func (daemon *Daemon) ContainerExecResize(name string, height, width int) error {
|
2015-07-30 17:01:53 -04:00
|
|
|
ExecConfig, err := daemon.getExecConfig(name)
|
2015-05-01 21:03:35 -04:00
|
|
|
if err != nil {
|
2015-03-25 03:44:12 -04:00
|
|
|
return err
|
2014-09-15 18:56:47 -04:00
|
|
|
}
|
2015-05-01 21:03:35 -04:00
|
|
|
|
2015-11-20 17:35:16 -05:00
|
|
|
return ExecConfig.Resize(height, width)
|
2014-09-15 18:56:47 -04:00
|
|
|
}
|