github.com/rhatdan/docker@v0.7.7-0.20180119204836-47a0dcbcd20a/daemon/resize.go (about) 1 package daemon 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/docker/docker/libcontainerd" 8 ) 9 10 // ContainerResize changes the size of the TTY of the process running 11 // in the container with the given name to the given height and width. 12 func (daemon *Daemon) ContainerResize(name string, height, width int) error { 13 container, err := daemon.GetContainer(name) 14 if err != nil { 15 return err 16 } 17 18 if !container.IsRunning() { 19 return errNotRunning(container.ID) 20 } 21 22 if err = daemon.containerd.ResizeTerminal(context.Background(), container.ID, libcontainerd.InitProcessName, width, height); err == nil { 23 attributes := map[string]string{ 24 "height": fmt.Sprintf("%d", height), 25 "width": fmt.Sprintf("%d", width), 26 } 27 daemon.LogContainerEventWithAttributes(container, "resize", attributes) 28 } 29 return err 30 } 31 32 // ContainerExecResize changes the size of the TTY of the process 33 // running in the exec with the given name to the given height and 34 // width. 35 func (daemon *Daemon) ContainerExecResize(name string, height, width int) error { 36 ec, err := daemon.getExecConfig(name) 37 if err != nil { 38 return err 39 } 40 return daemon.containerd.ResizeTerminal(context.Background(), ec.ContainerID, ec.ID, width, height) 41 }