diff --git a/pkg/commands/volume.go b/pkg/commands/volume.go index b6d92bf53a..40fbd59b21 100644 --- a/pkg/commands/volume.go +++ b/pkg/commands/volume.go @@ -50,7 +50,7 @@ func (v *VolumeCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile. existingVolumes[volume] = x util.AddVolumePathToWhitelist(volume) - // Only create and snapshot the dir if it didn't exist already + // Only create the dir if it didn't exist already if _, err := os.Stat(volume); os.IsNotExist(err) { logrus.Infof("Creating directory %s", volume) if err := os.MkdirAll(volume, 0755); err != nil { diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 4fff9e18db..6f7dc8ca02 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -239,6 +239,7 @@ func (s *stageBuilder) build() error { } cacheGroup := errgroup.Group{} + snapshotInitialized := false for index, command := range s.cmds { if command == nil { continue @@ -261,12 +262,13 @@ func (s *stageBuilder) build() error { cacheImg := command.CacheImage() if cacheImg == nil { - if command.RequiresUnpackedFS() && !command.MetadataOnly() { + if !snapshotInitialized && command.RequiresUnpackedFS() && !command.MetadataOnly() { // Prepare initial state for the FS diff t := timing.Start("Pre-command execution FS snapshot") logrus.Debug("Scanning pre-snapshot filesystem state") s.snapshotter.Init() timing.DefaultRun.Stop(t) + snapshotInitialized = true } } else { if shouldUnpack {