e0fd96f8 |
package daemon
|
9c4570a9 |
import ( |
ddae20c0 |
"context" |
9c4570a9 |
"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() { |
ebcb7d6b |
return errNotRunning(container.ID) |
bb0e7eb1 |
}
|
ddae20c0 |
if err = daemon.containerd.ResizeTerminal(context.Background(), container.ID, libcontainerd.InitProcessName, 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 |
} |
ddae20c0 |
return daemon.containerd.ResizeTerminal(context.Background(), ec.ContainerID, ec.ID, width, height) |
bfebdfde |
} |