code: func (s *Scheduler) instances(ctx context.Context, app string, labels ...string) ([]*twelvefactor.Task, error) {
  	var instances []*twelvefactor.Task
  
  	containers, err := s.docker.ListContainers(docker.ListContainersOptions{
  		Filters: map[string][]string{
  			"label": append([]string{
  				fmt.Sprintf("%s=%s", appLabel, app),
  			}, labels...),
  		},
  	})
  	if err != nil {
  		return nil, fmt.Errorf("error listing containers from attached runs: %v", err)
  	}
  
  	for _, apiContainer := range containers {
  		container, err := s.docker.InspectContainer(apiContainer.ID)
  		if err != nil {
  			return instances, fmt.Errorf("error inspecting container %s: %v", apiContainer.ID, err)
  		}
  
  		state := strings.ToUpper(container.State.StateString())
  
  		instances = append(instances, &twelvefactor.Task{
  			ID:        container.ID[0:12],
  			State:     state,
  			UpdatedAt: container.State.StartedAt,
  			Process: &twelvefactor.Process{
  				Type:      container.Config.Labels[processLabel],
  				Command:   container.Config.Cmd,
  				Env:       parseEnv(container.Config.Env),
  				Memory:    uint(container.HostConfig.Memory),
  				CPUShares: uint(container.HostConfig.CPUShares),
  			},
  		})
  	}
  
  	return instances, nil
  }
docs: // instances returns docker container instances for this app, optionally
  // filtered with labels.