diff --git a/pkg/stacker/build.go b/pkg/stacker/build.go index c1d30f76..819b86d3 100644 --- a/pkg/stacker/build.go +++ b/pkg/stacker/build.go @@ -820,6 +820,12 @@ func SetupLayerConfig(config types.StackerConfig, c *container.Container, l type } for _, bind := range l.Binds { + _, err := os.Stat(bind.Source) + // c.BindMount allows files to not exist and will create them, but not so for directories. + if os.IsNotExist(err) { + log.Errorf("bind mount source %q does not exist, refusing bind mount: %s", bind.Source, err) + return fmt.Errorf("bind mount source %q does not exist, refusing bind mount: %s", bind.Source, err) + } err = c.BindMount(bind.Source, bind.Dest, "") if err != nil { return err