github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/client/container_resize.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "net/url" 6 "strconv" 7 8 "github.com/docker/docker/api/types" 9 ) 10 11 // ContainerResize changes the size of the tty for a container. 12 func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error { 13 return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) 14 } 15 16 // ContainerExecResize changes the size of the tty for an exec process running inside a container. 17 func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error { 18 return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) 19 } 20 21 func (cli *Client) resize(ctx context.Context, basePath string, height, width uint) error { 22 query := url.Values{} 23 query.Set("h", strconv.Itoa(int(height))) 24 query.Set("w", strconv.Itoa(int(width))) 25 26 resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) 27 ensureReaderClosed(resp) 28 return err 29 }