resize.go 1013 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package daemon
  2. import "fmt"
  3. // ContainerResize changes the size of the TTY of the process running
  4. // in the container with the given name to the given height and width.
  5. func (daemon *Daemon) ContainerResize(name string, height, width int) error {
  6. container, err := daemon.GetContainer(name)
  7. if err != nil {
  8. return err
  9. }
  10. if !container.IsRunning() {
  11. return errNotRunning{container.ID}
  12. }
  13. if err = container.Resize(height, width); err == nil {
  14. attributes := map[string]string{
  15. "height": fmt.Sprintf("%d", height),
  16. "width": fmt.Sprintf("%d", width),
  17. }
  18. daemon.LogContainerEventWithAttributes(container, "resize", attributes)
  19. }
  20. return err
  21. }
  22. // ContainerExecResize changes the size of the TTY of the process
  23. // running in the exec with the given name to the given height and
  24. // width.
  25. func (daemon *Daemon) ContainerExecResize(name string, height, width int) error {
  26. ExecConfig, err := daemon.getExecConfig(name)
  27. if err != nil {
  28. return err
  29. }
  30. return ExecConfig.Resize(height, width)
  31. }