summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorPaweł Gronowski <pawel.gronowski@docker.com>2022-06-15 09:28:20 +0200
committerPaweł Gronowski <pawel.gronowski@docker.com>2022-06-24 11:54:25 +0200
commit56a20dbc19786633f605d3871f5242d8e0f1be5a (patch)
tree643532f01a56d1a491194fbcef31ba12432d4b1f /client
parent9c4987ee6b236de5e8ec213f7872fb3b9ee1aece (diff)
downloaddocker-56a20dbc19786633f605d3871f5242d8e0f1be5a.tar.gz
container/exec: Support ConsoleSize
Now client have the possibility to set the console size of the executed process immediately at the creation. This makes a difference for example when executing commands that output some kind of text user interface which is bounded by the console dimensions. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Diffstat (limited to 'client')
-rw-r--r--client/container_exec.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/client/container_exec.go b/client/container_exec.go
index e54da00fc6..6a2cb006f8 100644
--- a/client/container_exec.go
+++ b/client/container_exec.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"github.com/docker/docker/api/types"
+ "github.com/docker/docker/api/types/versions"
)
// ContainerExecCreate creates a new exec configuration to run an exec process.
@@ -14,6 +15,9 @@ func (cli *Client) ContainerExecCreate(ctx context.Context, container string, co
if err := cli.NewVersionError("1.25", "env"); len(config.Env) != 0 && err != nil {
return response, err
}
+ if versions.LessThan(cli.ClientVersion(), "1.42") {
+ config.ConsoleSize = nil
+ }
resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil)
defer ensureReaderClosed(resp)
@@ -26,6 +30,9 @@ func (cli *Client) ContainerExecCreate(ctx context.Context, container string, co
// ContainerExecStart starts an exec process already created in the docker host.
func (cli *Client) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error {
+ if versions.LessThan(cli.ClientVersion(), "1.42") {
+ config.ConsoleSize = nil
+ }
resp, err := cli.post(ctx, "/exec/"+execID+"/start", nil, config, nil)
ensureReaderClosed(resp)
return err
@@ -36,6 +43,9 @@ func (cli *Client) ContainerExecStart(ctx context.Context, execID string, config
// and the a reader to get output. It's up to the called to close
// the hijacked connection by calling types.HijackedResponse.Close.
func (cli *Client) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) {
+ if versions.LessThan(cli.ClientVersion(), "1.42") {
+ config.ConsoleSize = nil
+ }
headers := map[string][]string{
"Content-Type": {"application/json"},
}