summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/wait.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd/podman/wait.go b/cmd/podman/wait.go
index 27cfecac9..2b2a07738 100644
--- a/cmd/podman/wait.go
+++ b/cmd/podman/wait.go
@@ -14,11 +14,12 @@ var (
Block until one or more containers stop and then print their exit codes
`
-
+ waitFlags = []cli.Flag{LatestFlag}
waitCommand = cli.Command{
Name: "wait",
Usage: "Block on one or more containers",
Description: waitDescription,
+ Flags: waitFlags,
Action: waitCmd,
ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]",
}
@@ -26,7 +27,7 @@ var (
func waitCmd(c *cli.Context) error {
args := c.Args()
- if len(args) < 1 {
+ if len(args) < 1 && !c.Bool("latest") {
return errors.Errorf("you must provide at least one container name or id")
}
@@ -41,7 +42,15 @@ func waitCmd(c *cli.Context) error {
}
var lastError error
- for _, container := range c.Args() {
+ if c.Bool("latest") {
+ latestCtr, err := runtime.GetLatestContainer()
+ if err != nil {
+ return errors.Wrapf(err, "unable to wait on latest container")
+ }
+ args = append(args, latestCtr.ID())
+ }
+
+ for _, container := range args {
ctr, err := runtime.LookupContainer(container)
if err != nil {
return errors.Wrapf(err, "unable to find container %s", container)