diff --git a/internal/oci/runtime_oci.go b/internal/oci/runtime_oci.go index 9653b769916..6401cdb88d2 100644 --- a/internal/oci/runtime_oci.go +++ b/internal/oci/runtime_oci.go @@ -166,6 +166,9 @@ func (r *runtimeOCI) CreateContainer(ctx context.Context, c *Container, cgroupPa // Platform specific container setup if err := r.createContainerPlatform(c, cgroupParent, cmd.Process.Pid); err != nil { + if waitErr := cmd.Wait(); waitErr != nil { + return errors.Wrap(err, waitErr.Error()) + } return err } @@ -374,6 +377,9 @@ func (r *runtimeOCI) ExecContainer(ctx context.Context, c *Container, cmd []stri // The read side of the pipe should be closed after the container process has been started. if r != nil { if err := r.Close(); err != nil { + if waitErr := execCmd.Wait(); waitErr != nil { + return errors.Wrap(err, waitErr.Error()) + } return err } } diff --git a/internal/storage/image.go b/internal/storage/image.go index 812a3037960..26775e1d3d3 100644 --- a/internal/storage/image.go +++ b/internal/storage/image.go @@ -586,6 +586,9 @@ func (svc *imageService) copyImage(systemContext *types.SystemContext, imageName } if err := json.NewEncoder(stdin).Encode(&stdinArguments); err != nil { stdin.Close() + if waitErr := cmd.Wait(); waitErr != nil { + return errors.Wrap(err, waitErr.Error()) + } return errors.Wrap(err, "json encode to pipe failed") } stdin.Close()