summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/attach.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go
index 78b52ad1b..ee4d811d7 100644
--- a/cmd/podman/containers/attach.go
+++ b/cmd/podman/containers/attach.go
@@ -71,11 +71,18 @@ func init() {
}
func attach(cmd *cobra.Command, args []string) error {
+ if len(args) > 1 || (len(args) == 0 && !attachOpts.Latest) {
+ return errors.Errorf("attach requires the name or id of one running container or the latest flag")
+ }
+ var name string
+ if len(args) > 0 {
+ name = args[0]
+ }
attachOpts.Stdin = os.Stdin
if attachOpts.NoStdin {
attachOpts.Stdin = nil
}
attachOpts.Stdout = os.Stdout
attachOpts.Stderr = os.Stderr
- return registry.ContainerEngine().ContainerAttach(registry.GetContext(), args[0], attachOpts)
+ return registry.ContainerEngine().ContainerAttach(registry.GetContext(), name, attachOpts)
}