diff --git a/runtime/container.go b/runtime/container.go index ee545db201..72ee104d8b 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -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() diff --git a/server/server.go b/server/server.go index eb9a3a396b..69b65ce4a5 100644 --- a/server/server.go +++ b/server/server.go @@ -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)) }