code: func AllocatePorts(portMapper *portmapper.PortMapper, bindings []types.PortBinding, containerIP net.IP) ([]types.PortBinding, error) {
  	bs := make([]types.PortBinding, 0, len(bindings))
  	for _, c := range bindings {
  		b := c.GetCopy()
  		if err := allocatePort(portMapper, &b, containerIP); err != nil {
  			// On allocation failure, release previously allocated ports. On cleanup error, just log a warning message
  			if cuErr := ReleasePorts(portMapper, bs); cuErr != nil {
  				logrus.Warnf("Upon allocation failure for %v, failed to clear previously allocated port bindings: %v", b, cuErr)
  			}
  			return nil, err
  		}
  		bs = append(bs, b)
  	}
  	return bs, nil
  }
docs: // AllocatePorts allocates ports specified in bindings from the portMapper