code: func (daemon *Daemon) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error) {
  	if !atomic.CompareAndSwapInt32(&daemon.pruneRunning, 0, 1) {
  		return nil, errPruneRunning
  	}
  	defer atomic.StoreInt32(&daemon.pruneRunning, 0)
  
  	rep := &types.ContainersPruneReport{}
  
  	// make sure that only accepted filters have been received
  	err := pruneFilters.Validate(containersAcceptedFilters)
  	if err != nil {
  		return nil, err
  	}
  
  	until, err := getUntilFromPruneFilters(pruneFilters)
  	if err != nil {
  		return nil, err
  	}
  
  	allContainers := daemon.List()
  	for _, c := range allContainers {
  		select {
  		case <-ctx.Done():
  			logrus.Debugf("ContainersPrune operation cancelled: %#v", *rep)
  			return rep, nil
  		default:
  		}
  
  		if !c.IsRunning() {
  			if !until.IsZero() && c.Created.After(until) {
  				continue
  			}
  			if !matchLabels(pruneFilters, c.Config.Labels) {
  				continue
  			}
  			cSize, _ := daemon.imageService.GetContainerLayerSize(c.ID)
  			// TODO: sets RmLink to true?
  			err := daemon.ContainerRm(c.ID, &types.ContainerRmConfig{})
  			if err != nil {
  				logrus.Warnf("failed to prune container %s: %v", c.ID, err)
  				continue
  			}
  			if cSize > 0 {
  				rep.SpaceReclaimed += uint64(cSize)
  			}
  			rep.ContainersDeleted = append(rep.ContainersDeleted, c.ID)
  		}
  	}
  
  	return rep, nil
  }
docs: // ContainersPrune removes unused containers