diff --git a/internal/lib/checkpoint.go b/internal/lib/checkpoint.go index 7776997b203..e73fbad7625 100644 --- a/internal/lib/checkpoint.go +++ b/internal/lib/checkpoint.go @@ -84,6 +84,12 @@ func (c *ContainerServer) ContainerCheckpoint( if err := c.exportCheckpoint(ctx, ctr, specgen.Config, opts.TargetFile); err != nil { return "", fmt.Errorf("failed to write file system changes of container %s: %w", ctr.ID(), err) } + defer func() { + // clean up checkpoint directory + if err := os.RemoveAll(ctr.CheckpointPath()); err != nil { + log.Warnf(ctx, "Unable to remove checkpoint directory %s: %v", ctr.CheckpointPath(), err) + } + }() } if !opts.KeepRunning { if err := c.storageRuntimeServer.StopContainer(ctx, ctr.ID()); err != nil {