summaryrefslogtreecommitdiff
path: root/cmd/podman/start.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-01-02 16:29:43 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-08 19:12:17 +0000
commit7b08aa78e4ede4c54fda6cd9917bb62e18d0d634 (patch)
tree1c480d9dfb8db3268dc3fdcca827792278a3ae47 /cmd/podman/start.go
parent6baf6e461de6e560cc48d35239e7c392bec4481c (diff)
downloadpodman-7b08aa78e4ede4c54fda6cd9917bb62e18d0d634.tar.gz
podman-7b08aa78e4ede4c54fda6cd9917bb62e18d0d634.tar.bz2
podman-7b08aa78e4ede4c54fda6cd9917bb62e18d0d634.zip
Shortcut for most recent container
It is desirable to have a shortcut for the most recently created container. We can now use "**latest" to represent the most recent container instead of its container ID or name. For example: Signed-off-by: baude <bbaude@redhat.com> Closes: #179 Approved by: baude
Diffstat (limited to 'cmd/podman/start.go')
-rw-r--r--cmd/podman/start.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd/podman/start.go b/cmd/podman/start.go
index d4ddfbbe7..0dad5e237 100644
--- a/cmd/podman/start.go
+++ b/cmd/podman/start.go
@@ -26,6 +26,7 @@ var (
Name: "interactive, i",
Usage: "Keep STDIN open even if not attached",
},
+ LatestFlag,
}
startDescription = `
podman start
@@ -46,7 +47,7 @@ var (
func startCmd(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")
}
@@ -65,7 +66,13 @@ func startCmd(c *cli.Context) error {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
-
+ if c.Bool("latest") {
+ lastCtr, err := runtime.GetLatestContainer()
+ if err != nil {
+ return errors.Wrapf(err, "unable to get latest container")
+ }
+ args = append(args, lastCtr.ID())
+ }
var lastError error
for _, container := range args {
// Create a bool channel to track that the console socket attach