Browse Source

Merge pull request #2457 from dotcloud/2454_do_not_split_last_column

RemoteAPI: Do not split last column docker top
Victor Vieux 11 years ago
parent
commit
8f27e23b4b
3 changed files with 7 additions and 3 deletions
  1. 1 1
      commands.go
  2. 1 1
      docs/sources/commandline/cli.rst
  3. 5 1
      server.go

+ 1 - 1
commands.go

@@ -683,7 +683,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
 }
 }
 
 
 func (cli *DockerCli) CmdTop(args ...string) error {
 func (cli *DockerCli) CmdTop(args ...string) error {
-	cmd := Subcmd("top", "CONTAINER", "Lookup the running processes of a container")
+	cmd := Subcmd("top", "CONTAINER [ps OPTIONS]", "Lookup the running processes of a container")
 	if err := cmd.Parse(args); err != nil {
 	if err := cmd.Parse(args); err != nil {
 		return nil
 		return nil
 	}
 	}

+ 1 - 1
docs/sources/commandline/cli.rst

@@ -729,7 +729,7 @@ The main process inside the container will receive SIGTERM, and after a grace pe
 
 
 ::
 ::
 
 
-    Usage: docker top CONTAINER
+    Usage: docker top CONTAINER [ps OPTIONS]
 
 
     Lookup the running processes of a container
     Lookup the running processes of a container
 
 

+ 5 - 1
server.go

@@ -416,7 +416,11 @@ func (srv *Server) ContainerTop(name, ps_args string) (*APITop, error) {
 			}
 			}
 			// no scanner.Text because we skip container id
 			// no scanner.Text because we skip container id
 			for scanner.Scan() {
 			for scanner.Scan() {
-				words = append(words, scanner.Text())
+				if i != 0 && len(words) == len(procs.Titles) {
+					words[len(words)-1] = fmt.Sprintf("%s %s", words[len(words)-1], scanner.Text())
+				} else {
+					words = append(words, scanner.Text())
+				}
 			}
 			}
 			if i == 0 {
 			if i == 0 {
 				procs.Titles = words
 				procs.Titles = words