summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/containers/wait.go9
-rw-r--r--docs/source/markdown/podman-wait.1.md14
-rw-r--r--test/e2e/wait_test.go20
3 files changed, 37 insertions, 6 deletions
diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go
index 74ee6073a..9bb39e978 100644
--- a/cmd/podman/containers/wait.go
+++ b/cmd/podman/containers/wait.go
@@ -23,7 +23,6 @@ var (
Short: "Block on one or more containers",
Long: waitDescription,
RunE: wait,
- Args: validate.IDOrLatestArgs,
Example: `podman wait --interval 5000 ctrID
podman wait ctrID1 ctrID2`,
}
@@ -33,7 +32,6 @@ var (
Short: waitCommand.Short,
Long: waitCommand.Long,
RunE: waitCommand.RunE,
- Args: validate.IDOrLatestArgs,
Example: `podman container wait --interval 5000 ctrID
podman container wait ctrID1 ctrID2`,
}
@@ -76,6 +74,13 @@ func wait(cmd *cobra.Command, args []string) error {
return errors.New("interval must be greater then 0")
}
+ if !waitOptions.Latest && len(args) == 0 {
+ return errors.Errorf("%q requires a name, id, or the \"--latest\" flag", cmd.CommandPath())
+ }
+ if waitOptions.Latest && len(args) > 0 {
+ return errors.New("--latest and containers are not allowed")
+ }
+
waitOptions.Condition, err = define.StringToContainerStatus(waitCondition)
if err != nil {
return err
diff --git a/docs/source/markdown/podman-wait.1.md b/docs/source/markdown/podman-wait.1.md
index 886bbc55b..1d85e9af0 100644
--- a/docs/source/markdown/podman-wait.1.md
+++ b/docs/source/markdown/podman-wait.1.md
@@ -4,14 +4,15 @@
podman\-wait - Wait on one or more containers to stop and print their exit codes
## SYNOPSIS
-**podman wait** [*options*] *container*
+**podman wait** [*options*] *container* [...]
-**podman container wait** [*options*] *container*
+**podman container wait** [*options*] *container* [...]
## DESCRIPTION
Waits on one or more containers to stop. The container can be referred to by its
-name or ID. In the case of multiple containers, podman will wait on each consecutively.
-After the container stops, the container's return code is printed.
+name or ID. In the case of multiple containers, Podman will wait on each consecutively.
+After all specified containers are stopped, the containers' return codes are printed
+separated by newline in the same order as they were given to the command.
## OPTIONS
@@ -36,12 +37,17 @@ The latest option is not supported on the remote client.
```
$ podman wait mywebserver
+0
$ podman wait --latest
+0
$ podman wait 860a4b23
+1
$ podman wait mywebserver myftpserver
+0
+125
```
## SEE ALSO
diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go
index 3758acab8..4f0129a47 100644
--- a/test/e2e/wait_test.go
+++ b/test/e2e/wait_test.go
@@ -64,6 +64,7 @@ var _ = Describe("Podman wait", func() {
session = podmanTest.Podman([]string{"wait", "-l"})
session.Wait(20)
})
+
It("podman container wait on latest container", func() {
session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"})
session.Wait(20)
@@ -71,4 +72,23 @@ var _ = Describe("Podman wait", func() {
session = podmanTest.Podman([]string{"container", "wait", "-l"})
session.Wait(20)
})
+
+ It("podman wait on three containers", func() {
+ session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"})
+ session.Wait(20)
+ Expect(session.ExitCode()).To(Equal(0))
+ cid1 := session.OutputToString()
+ session = podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"})
+ session.Wait(20)
+ Expect(session.ExitCode()).To(Equal(0))
+ cid2 := session.OutputToString()
+ session = podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"})
+ session.Wait(20)
+ Expect(session.ExitCode()).To(Equal(0))
+ cid3 := session.OutputToString()
+ session = podmanTest.Podman([]string{"wait", cid1, cid2, cid3})
+ session.Wait(20)
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToStringArray()).To(Equal([]string{"0", "0", "0"}))
+ })
})