mirror of https://github.com/docker/docs.git
add -l to docker ps
This commit is contained in:
parent
f507188ddc
commit
8c3331dc97
12
commands.go
12
commands.go
|
@ -647,17 +647,25 @@ func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
quiet := cmd.Bool("q", false, "Only display numeric IDs")
|
quiet := cmd.Bool("q", false, "Only display numeric IDs")
|
||||||
flAll := cmd.Bool("a", false, "Show all containers. Only running containers are shown by default.")
|
flAll := cmd.Bool("a", false, "Show all containers. Only running containers are shown by default.")
|
||||||
flFull := cmd.Bool("notrunc", false, "Don't truncate output")
|
flFull := cmd.Bool("notrunc", false, "Don't truncate output")
|
||||||
|
latest := cmd.Bool("l", false, "Show only the latest created container, include non-running ones.")
|
||||||
|
n_last := cmd.Int("last", -1, "Show last created containers, include non-running ones.")
|
||||||
if err := cmd.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if *n_last == -1 && *latest {
|
||||||
|
*n_last = 1
|
||||||
|
}
|
||||||
w := tabwriter.NewWriter(stdout, 12, 1, 3, ' ', 0)
|
w := tabwriter.NewWriter(stdout, 12, 1, 3, ' ', 0)
|
||||||
if !*quiet {
|
if !*quiet {
|
||||||
fmt.Fprintln(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tCOMMENT")
|
fmt.Fprintln(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tCOMMENT")
|
||||||
}
|
}
|
||||||
for _, container := range srv.runtime.List() {
|
for i, container := range srv.runtime.List() {
|
||||||
if !container.State.Running && !*flAll {
|
if !container.State.Running && !*flAll && *n_last == -1{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if i == *n_last {
|
||||||
|
break
|
||||||
|
}
|
||||||
if !*quiet {
|
if !*quiet {
|
||||||
command := fmt.Sprintf("%s %s", container.Path, strings.Join(container.Args, " "))
|
command := fmt.Sprintf("%s %s", container.Path, strings.Join(container.Args, " "))
|
||||||
if !*flFull {
|
if !*flFull {
|
||||||
|
|
Loading…
Reference in New Issue