Add podman container ps command

This command exists in docker and is also in our documentation.

Also remove mentions of `podman ls` or `podman list`. These
commands do not exists in podman or docker.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
Paul Holzinger 2020-11-22 23:55:25 +01:00
parent 5292d5a7b8
commit c901a766fb
7 changed files with 30 additions and 9 deletions

View File

@ -29,15 +29,25 @@ var (
psDescription = "Prints out information about the containers" psDescription = "Prints out information about the containers"
psCommand = &cobra.Command{ psCommand = &cobra.Command{
Use: "ps [options]", Use: "ps [options]",
Args: validate.NoArgs,
Short: "List containers", Short: "List containers",
Long: psDescription, Long: psDescription,
RunE: ps, RunE: ps,
Args: validate.NoArgs,
ValidArgsFunction: completion.AutocompleteNone, ValidArgsFunction: completion.AutocompleteNone,
Example: `podman ps -a Example: `podman ps -a
podman ps -a --format "{{.ID}} {{.Image}} {{.Labels}} {{.Mounts}}" podman ps -a --format "{{.ID}} {{.Image}} {{.Labels}} {{.Mounts}}"
podman ps --size --sort names`, podman ps --size --sort names`,
} }
psContainerCommand = &cobra.Command{
Use: psCommand.Use,
Short: psCommand.Short,
Long: psCommand.Long,
RunE: psCommand.RunE,
Args: psCommand.Args,
ValidArgsFunction: psCommand.ValidArgsFunction,
Example: strings.ReplaceAll(psCommand.Example, "podman ps", "podman container ps"),
}
) )
var ( var (
listOpts = entities.ContainerListOptions{ listOpts = entities.ContainerListOptions{
@ -54,6 +64,14 @@ func init() {
}) })
listFlagSet(psCommand) listFlagSet(psCommand)
validate.AddLatestFlag(psCommand, &listOpts.Latest) validate.AddLatestFlag(psCommand, &listOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: psContainerCommand,
Parent: containerCmd,
})
listFlagSet(psContainerCommand)
validate.AddLatestFlag(psContainerCommand, &listOpts.Latest)
} }
func listFlagSet(cmd *cobra.Command) { func listFlagSet(cmd *cobra.Command) {

View File

@ -39,6 +39,8 @@ Manage Containers
:doc:`prune <markdown/podman-container-prune.1>` Remove all stopped containers :doc:`prune <markdown/podman-container-prune.1>` Remove all stopped containers
:doc:`ps <markdown/podman-ps.1>` List containers
:doc:`restart <markdown/podman-restart.1>` Restart one or more containers :doc:`restart <markdown/podman-restart.1>` Restart one or more containers
:doc:`restore <markdown/podman-container-restore.1>` Restores one or more containers from a checkpoint :doc:`restore <markdown/podman-container-restore.1>` Restores one or more containers from a checkpoint

View File

@ -1 +0,0 @@
.so man1/podman-ps.1

View File

@ -1 +0,0 @@
.so man1/podman-ps.1

View File

@ -32,6 +32,7 @@ The container command allows you to manage containers
| pause | [podman-pause(1)](podman-pause.1.md) | Pause one or more containers. | | pause | [podman-pause(1)](podman-pause.1.md) | Pause one or more containers. |
| port | [podman-port(1)](podman-port.1.md) | List port mappings for the container. | | port | [podman-port(1)](podman-port.1.md) | List port mappings for the container. |
| prune | [podman-container-prune(1)](podman-container-prune.1.md)| Remove all stopped containers from local storage. | | prune | [podman-container-prune(1)](podman-container-prune.1.md)| Remove all stopped containers from local storage. |
| ps | [podman-ps(1)](podman-ps.1.md) | Prints out information about containers. |
| restart | [podman-restart(1)](podman-restart.1.md) | Restart one or more containers. | | restart | [podman-restart(1)](podman-restart.1.md) | Restart one or more containers. |
| restore | [podman-container-restore(1)](podman-container-restore.1.md) | Restores one or more containers from a checkpoint. | | restore | [podman-container-restore(1)](podman-container-restore.1.md) | Restores one or more containers from a checkpoint. |
| rm | [podman-rm(1)](podman-rm.1.md) | Remove one or more containers. | | rm | [podman-rm(1)](podman-rm.1.md) | Remove one or more containers. |

View File

@ -6,16 +6,12 @@ podman\-ps - Prints out information about containers
## SYNOPSIS ## SYNOPSIS
**podman ps** [*options*] **podman ps** [*options*]
**podman container ps** [*options*]
**podman container list** [*options*] **podman container list** [*options*]
**podman container ls** [*options*] **podman container ls** [*options*]
**podman container ps** [*options*]
**podman list** [*options*]
**podman ls** [*options*]
## DESCRIPTION ## DESCRIPTION
**podman ps** lists the running containers on the system. Use the **--all** flag to view **podman ps** lists the running containers on the system. Use the **--all** flag to view
all the containers information. By default it lists: all the containers information. By default it lists:

View File

@ -44,6 +44,12 @@ var _ = Describe("Podman ps", func() {
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
}) })
It("podman container ps no containers", func() {
session := podmanTest.Podman([]string{"container", "ps"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
It("podman ps default", func() { It("podman ps default", func() {
session := podmanTest.RunTopContainer("") session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()