summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate/container_create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-22 11:03:46 -0400
committerGitHub <noreply@github.com>2020-10-22 11:03:46 -0400
commit2cb12bbc5a832e5b69d3b52480377df716dc543b (patch)
treea475bf30f9fde2ee989e83620c03049bd2d82654 /pkg/specgen/generate/container_create.go
parent513c2610f37fa530b951a9a0105f49dfd346c091 (diff)
parent410fa53f89b1c408ce57318bb054b4229ad845d5 (diff)
downloadpodman-2cb12bbc5a832e5b69d3b52480377df716dc543b.tar.gz
podman-2cb12bbc5a832e5b69d3b52480377df716dc543b.tar.bz2
podman-2cb12bbc5a832e5b69d3b52480377df716dc543b.zip
Merge pull request #8098 from vrothberg/fix-8082
container create: record correct image name
Diffstat (limited to 'pkg/specgen/generate/container_create.go')
-rw-r--r--pkg/specgen/generate/container_create.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index 105e36bc6..f051537de 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
+ "strings"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v2/libpod"
@@ -91,11 +92,19 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
if err != nil {
return nil, err
}
- imgName := s.Image
- names := newImage.Names()
- if len(names) > 0 {
- imgName = names[0]
+ // If the input name changed, we could properly resolve the
+ // image. Otherwise, it must have been an ID where we're
+ // defaulting to the first name or an empty one if no names are
+ // present.
+ imgName := newImage.InputName
+ if s.Image == newImage.InputName && strings.HasPrefix(newImage.ID(), s.Image) {
+ imgName = ""
+ names := newImage.Names()
+ if len(names) > 0 {
+ imgName = names[0]
+ }
}
+
options = append(options, libpod.WithRootFSFromImage(newImage.ID(), imgName, s.RawImageName))
}
if err := s.Validate(); err != nil {