diff --git a/commands.go b/commands.go index 4c9f9aedc2..fd314c8d66 100644 --- a/commands.go +++ b/commands.go @@ -683,7 +683,7 @@ func (cli *DockerCli) CmdInspect(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 { return nil } diff --git a/docs/sources/commandline/cli.rst b/docs/sources/commandline/cli.rst index 8f778c32de..c85c602117 100644 --- a/docs/sources/commandline/cli.rst +++ b/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 diff --git a/server.go b/server.go index a58daf54e1..db185f8151 100644 --- a/server.go +++ b/server.go @@ -416,7 +416,11 @@ func (srv *Server) ContainerTop(name, ps_args string) (*APITop, error) { } // no scanner.Text because we skip container id 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 { procs.Titles = words