diff options
Diffstat (limited to 'libpod/container_validate.go')
-rw-r--r-- | libpod/container_validate.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libpod/container_validate.go b/libpod/container_validate.go index 6ff46f1b1..91ebe93fb 100644 --- a/libpod/container_validate.go +++ b/libpod/container_validate.go @@ -131,5 +131,11 @@ func (c *Container) validate() error { if c.config.User == "" && (c.config.Spec.Process.User.UID != 0 || c.config.Spec.Process.User.GID != 0) { return errors.Wrapf(define.ErrInvalidArg, "please set User explicitly via WithUser() instead of in OCI spec directly") } + + // Init-ctrs must be used inside a Pod. Check if a init container type is + // passed and if no pod is passed + if len(c.config.InitContainerType) > 0 && len(c.config.Pod) < 1 { + return errors.Wrap(define.ErrInvalidArg, "init containers must be created in a pod") + } return nil } |