mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-04 20:51:44 +00:00
Merge remote-tracking branch 'origin/264-remove_cmdAttach_option'
This commit is contained in:
+12
-19
@@ -778,10 +778,7 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||
}
|
||||
|
||||
func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||
cmd := rcli.Subcmd(stdout, "attach", "[OPTIONS]", "Attach to a running container")
|
||||
flStdin := cmd.Bool("i", false, "Attach to stdin")
|
||||
flStdout := cmd.Bool("o", true, "Attach to stdout")
|
||||
flStderr := cmd.Bool("e", true, "Attach to stderr")
|
||||
cmd := rcli.Subcmd(stdout, "attach", "CONTAINER", "Attach to a running container")
|
||||
if err := cmd.Parse(args); err != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -795,7 +792,7 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||
return errors.New("No such container: " + name)
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
if *flStdin {
|
||||
if container.Config.OpenStdin {
|
||||
cStdin, err := container.StdinPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -803,22 +800,18 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...stri
|
||||
wg.Add(1)
|
||||
go func() { io.Copy(cStdin, stdin); wg.Add(-1) }()
|
||||
}
|
||||
if *flStdout {
|
||||
cStdout, err := container.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wg.Add(1)
|
||||
go func() { io.Copy(stdout, cStdout); wg.Add(-1) }()
|
||||
cStdout, err := container.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if *flStderr {
|
||||
cStderr, err := container.StderrPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wg.Add(1)
|
||||
go func() { io.Copy(stdout, cStderr); wg.Add(-1) }()
|
||||
wg.Add(1)
|
||||
go func() { io.Copy(stdout, cStdout); wg.Add(-1) }()
|
||||
cStderr, err := container.StderrPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wg.Add(1)
|
||||
go func() { io.Copy(stdout, cStderr); wg.Add(-1) }()
|
||||
wg.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user