1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

display command display in docker ps

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
Victor Vieux 2014-03-17 18:36:15 +00:00
parent 555c1ef670
commit 5921b186d1
2 changed files with 13 additions and 1 deletions

View file

@ -402,6 +402,18 @@ func populateCommand(c *Container) {
c.command.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
}
func (container *Container) ArgsAsString() string {
var args []string
for _, arg := range container.Args {
if strings.Contains(arg, " ") {
args = append(args, fmt.Sprintf("'%s'", arg))
} else {
args = append(args, arg)
}
}
return strings.Join(args, " ")
}
func (container *Container) Start() (err error) {
container.Lock()
defer container.Unlock()

View file

@ -1003,7 +1003,7 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
out.SetList("Names", names[container.ID])
out.Set("Image", srv.runtime.Repositories().ImageName(container.Image))
if len(container.Args) > 0 {
out.Set("Command", fmt.Sprintf("\"%s %s\"", container.Path, strings.Join(container.Args, " ")))
out.Set("Command", fmt.Sprintf("\"%s %s\"", container.Path, container.ArgsAsString()))
} else {
out.Set("Command", fmt.Sprintf("\"%s\"", container.Path))
}