Ver código fonte

Move the attach prevention from server to client

Guillaume J. Charmes 12 anos atrás
pai
commit
c106ed32ea
2 arquivos alterados com 4 adições e 3 exclusões
  1. 4 0
      commands.go
  2. 0 3
      server.go

+ 4 - 0
commands.go

@@ -1058,6 +1058,10 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
 		return err
 	}
 
+	if !container.State.Running {
+		return fmt.Errorf("Impossible to attach to a stopped container, start it first")
+	}
+
 	splitStderr := container.Config.Tty
 
 	connections := 1

+ 0 - 3
server.go

@@ -930,9 +930,6 @@ func (srv *Server) ContainerAttach(name string, logs, stream, stdin, stdout, std
 		if container.State.Ghost {
 			return fmt.Errorf("Impossible to attach to a ghost container")
 		}
-		if !container.State.Running {
-			return fmt.Errorf("Impossible to attach to a stopped container, start it first")
-		}
 
 		var (
 			cStdin           io.ReadCloser