diff options
author | Zhang Wei <zhangwei555@huawei.com> | 2016-03-23 19:34:47 +0800 |
---|---|---|
committer | Zhang Wei <zhangwei555@huawei.com> | 2016-04-04 15:35:55 +0800 |
commit | 91e5bb954131904af150b06bd22b007559a8ce27 (patch) | |
tree | 2cd1225043caaafafd96be0cecb19fa5ff7ab945 /daemon/attach.go | |
parent | e1a4332c13d0bdc5e960102a4f0dfd8e1fb6ffaf (diff) | |
download | docker-91e5bb954131904af150b06bd22b007559a8ce27.tar.gz |
Let client print error when speicify wrong detach keys
Fix #21064
Let client print error message explicitly when user specifies wrong
detach keys.
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Diffstat (limited to 'daemon/attach.go')
-rw-r--r-- | daemon/attach.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/daemon/attach.go b/daemon/attach.go index 79e9cd51da..73ae907401 100644 --- a/daemon/attach.go +++ b/daemon/attach.go @@ -11,10 +11,20 @@ import ( "github.com/docker/docker/daemon/logger" "github.com/docker/docker/errors" "github.com/docker/docker/pkg/stdcopy" + "github.com/docker/docker/pkg/term" ) // ContainerAttach attaches to logs according to the config passed in. See ContainerAttachConfig. func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerAttachConfig) error { + keys := []byte{} + var err error + if c.DetachKeys != "" { + keys, err = term.ToBytes(c.DetachKeys) + if err != nil { + return fmt.Errorf("Invalid escape keys (%s) provided", c.DetachKeys) + } + } + container, err := daemon.GetContainer(prefixOrName) if err != nil { return err @@ -48,7 +58,7 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA stderr = errStream } - if err := daemon.containerAttach(container, stdin, stdout, stderr, c.Logs, c.Stream, c.DetachKeys); err != nil { + if err := daemon.containerAttach(container, stdin, stdout, stderr, c.Logs, c.Stream, keys); err != nil { fmt.Fprintf(outStream, "Error attaching: %s\n", err) } return nil |