summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate/container.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/specgen/generate/container.go')
-rw-r--r--pkg/specgen/generate/container.go49
1 files changed, 17 insertions, 32 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index de3239fda..92a2b4d35 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -3,24 +3,38 @@ package generate
import (
"context"
+ "github.com/containers/image/v5/manifest"
"github.com/containers/libpod/libpod"
ann "github.com/containers/libpod/pkg/annotations"
envLib "github.com/containers/libpod/pkg/env"
"github.com/containers/libpod/pkg/signal"
"github.com/containers/libpod/pkg/specgen"
- "github.com/pkg/errors"
"golang.org/x/sys/unix"
)
func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerator) error {
- var appendEntryPoint bool
+ // If a rootfs is used, then there is no image data
+ if s.ContainerStorageConfig.Rootfs != "" {
+ return nil
+ }
- // TODO add support for raw rootfs
newImage, err := r.ImageRuntime().NewFromLocal(s.Image)
if err != nil {
return err
}
+ _, mediaType, err := newImage.Manifest(ctx)
+ if err != nil {
+ return err
+ }
+
+ if s.HealthConfig == nil && mediaType == manifest.DockerV2Schema2MediaType {
+ s.HealthConfig, err = newImage.GetHealthCheck(ctx)
+ if err != nil {
+ return err
+ }
+ }
+
// Image stop signal
if s.StopSignal == nil {
stopSignal, err := newImage.StopSignal(ctx)
@@ -96,28 +110,6 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
}
s.Annotations = annotations
- // entrypoint
- entrypoint, err := newImage.Entrypoint(ctx)
- if err != nil {
- return err
- }
- if len(s.Entrypoint) < 1 && len(entrypoint) > 0 {
- appendEntryPoint = true
- s.Entrypoint = entrypoint
- }
- command, err := newImage.Cmd(ctx)
- if err != nil {
- return err
- }
- if len(s.Command) < 1 && len(command) > 0 {
- if appendEntryPoint {
- s.Command = entrypoint
- }
- s.Command = append(s.Command, command...)
- }
- if len(s.Command) < 1 && len(s.Entrypoint) < 1 {
- return errors.Errorf("No command provided or as CMD or ENTRYPOINT in this image")
- }
// workdir
workingDir, err := newImage.WorkingDir(ctx)
if err != nil {
@@ -140,13 +132,6 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
if err != nil {
return err
}
-
- // TODO This should be enabled when namespaces actually work
- //case usernsMode.IsKeepID():
- // user = fmt.Sprintf("%d:%d", rootless.GetRootlessUID(), rootless.GetRootlessGID())
- if len(s.User) == 0 {
- s.User = "0"
- }
}
if err := finishThrottleDevices(s); err != nil {
return err