code: func (c *DefaultCleaner) Cleanup(config *api.Config) {
  	if config.PreserveWorkingDir {
  		glog.V(2).Infof("Temporary directory %q will be saved, not deleted", config.WorkingDir)
  	} else {
  		glog.V(2).Infof("Removing temporary directory %s", config.WorkingDir)
  		if err := c.fs.RemoveDirectory(config.WorkingDir); err != nil {
  			glog.Warningf("Error removing temporary directory %q: %v", config.WorkingDir, err)
  		}
  	}
  	if config.LayeredBuild {
  		// config.LayeredBuild is true only when layered build was finished successfully.
  		// Also in this case config.BuilderImage contains name of the new just built image,
  		// not the original one that was specified by the user.
  		glog.V(2).Infof("Removing temporary image %s", config.BuilderImage)
  		if err := c.docker.RemoveImage(config.BuilderImage); err != nil {
  			glog.Warningf("Error removing temporary image %s: %v", config.BuilderImage, err)
  		}
  	}
  }
docs: // Cleanup removes the temporary directories where the sources were stored for build.