mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
15aa2a663b
Implement configurable detach keys (for `attach`, exec`, `run` and `start`) using the client-side configuration - Adds a `--detach-keys` flag to `attach`, `exec`, `run` and `start` commands. - Adds a new configuration field (in `~/.docker/config.json`) to configure the default escape keys for docker client. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
33 lines
921 B
Go
33 lines
921 B
Go
package lib
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
)
|
|
|
|
// ContainerAttach attaches a connection to a container in the server.
|
|
// It returns a types.HijackedConnection with the hijacked connection
|
|
// 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) ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error) {
|
|
query := url.Values{}
|
|
if options.Stream {
|
|
query.Set("stream", "1")
|
|
}
|
|
if options.Stdin {
|
|
query.Set("stdin", "1")
|
|
}
|
|
if options.Stdout {
|
|
query.Set("stdout", "1")
|
|
}
|
|
if options.Stderr {
|
|
query.Set("stderr", "1")
|
|
}
|
|
if options.DetachKeys != "" {
|
|
query.Set("detachKeys", options.DetachKeys)
|
|
}
|
|
|
|
headers := map[string][]string{"Content-Type": {"text/plain"}}
|
|
return cli.postHijacked("/containers/"+options.ContainerID+"/attach", query, nil, headers)
|
|
}
|