2014-07-31 20:53:22 +00:00
|
|
|
package daemon
|
|
|
|
|
2015-11-05 13:40:42 -08:00
|
|
|
import derr "github.com/docker/docker/errors"
|
|
|
|
|
2015-07-30 14:01:53 -07: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 {
|
|
|
|
container, err := daemon.Get(name)
|
2014-09-15 22:56:47 +00:00
|
|
|
if err != nil {
|
2015-03-25 08:44:12 +01:00
|
|
|
return err
|
2014-09-15 22:56:47 +00:00
|
|
|
}
|
2015-05-02 03:03:35 +02:00
|
|
|
|
2015-11-05 13:40:42 -08: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 {
|
|
|
|
daemon.LogContainerEvent(container, "resize")
|
|
|
|
}
|
|
|
|
return err
|
2015-05-02 03:03:35 +02:00
|
|
|
}
|
|
|
|
|
2015-07-30 14:01:53 -07: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 14:01:53 -07:00
|
|
|
ExecConfig, err := daemon.getExecConfig(name)
|
2015-05-02 03:03:35 +02:00
|
|
|
if err != nil {
|
2015-03-25 08:44:12 +01:00
|
|
|
return err
|
2014-09-15 22:56:47 +00:00
|
|
|
}
|
2015-05-02 03:03:35 +02:00
|
|
|
|
2015-07-30 14:01:53 -07:00
|
|
|
return ExecConfig.resize(height, width)
|
2014-09-15 22:56:47 +00:00
|
|
|
}
|