summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-31 19:03:08 +0100
committerGitHub <noreply@github.com>2019-10-31 19:03:08 +0100
commit1e750f7ca874ed24781de27cccf0346e5ec247bf (patch)
tree919b048f177df745bc9c3a0334d438cf42731574 /pkg/adapter/containers.go
parent5af166ff513265b17aee92a9ce3a1522090d7dec (diff)
parentdc3e3af25613700bce3a8e2b2ce3e3f978ca0e9f (diff)
downloadpodman-1e750f7ca874ed24781de27cccf0346e5ec247bf.tar.gz
podman-1e750f7ca874ed24781de27cccf0346e5ec247bf.tar.bz2
podman-1e750f7ca874ed24781de27cccf0346e5ec247bf.zip
Merge pull request #4394 from vrothberg/fix-start
container start: fix regression when using name
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 430b6925d..207cf5c64 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -656,20 +656,25 @@ func (r *LocalRuntime) Start(ctx context.Context, c *cliconfig.StartValues, sigP
return exitCode, nil
}
- if ctrRunning {
- fmt.Println(ctr.ID())
- continue
- }
- // Handle non-attach start
- // If the container is in a pod, also set to recursively start dependencies
- if err := ctr.Start(ctx, ctr.PodID() != ""); err != nil {
- if lastError != nil {
- fmt.Fprintln(os.Stderr, lastError)
+ // Start the container if it's not running already.
+ if !ctrRunning {
+ // Handle non-attach start
+ // If the container is in a pod, also set to recursively start dependencies
+ if err := ctr.Start(ctx, ctr.PodID() != ""); err != nil {
+ if lastError != nil {
+ fmt.Fprintln(os.Stderr, lastError)
+ }
+ lastError = errors.Wrapf(err, "unable to start container %q", container)
+ continue
}
- lastError = errors.Wrapf(err, "unable to start container %q", container)
- continue
}
- fmt.Println(ctr.ID())
+ // Check if the container is referenced by ID or by name and print
+ // it accordingly.
+ if strings.HasPrefix(ctr.ID(), container) {
+ fmt.Println(ctr.ID())
+ } else {
+ fmt.Println(container)
+ }
}
return exitCode, lastError
}