daemon/resize.go
e0fd96f8
 package daemon
 
9c4570a9
 import (
 	"fmt"
 
 	"github.com/docker/docker/libcontainerd"
 )
bb0e7eb1
 
abd72d40
 // ContainerResize changes the size of the TTY of the process running
 // in the container with the given name to the given height and width.
b08f071e
 func (daemon *Daemon) ContainerResize(name string, height, width int) error {
d7d512bb
 	container, err := daemon.GetContainer(name)
bfebdfde
 	if err != nil {
c79b9bab
 		return err
bfebdfde
 	}
c7cfdb65
 
bb0e7eb1
 	if !container.IsRunning() {
a793564b
 		return errNotRunning{container.ID}
bb0e7eb1
 	}
 
9c4570a9
 	if err = daemon.containerd.Resize(container.ID, libcontainerd.InitFriendlyName, width, height); err == nil {
1d8ccc6a
 		attributes := map[string]string{
 			"height": fmt.Sprintf("%d", height),
 			"width":  fmt.Sprintf("%d", width),
 		}
 		daemon.LogContainerEventWithAttributes(container, "resize", attributes)
ca5ede2d
 	}
 	return err
c7cfdb65
 }
 
abd72d40
 // ContainerExecResize changes the size of the TTY of the process
 // running in the exec with the given name to the given height and
 // width.
b08f071e
 func (daemon *Daemon) ContainerExecResize(name string, height, width int) error {
9c4570a9
 	ec, err := daemon.getExecConfig(name)
c7cfdb65
 	if err != nil {
c79b9bab
 		return err
bfebdfde
 	}
9c4570a9
 	return daemon.containerd.Resize(ec.ContainerID, ec.ID, width, height)
bfebdfde
 }