| 285 | } |
| 286 | |
| 287 | func nextContainerNumber(containers []container.Summary) int { |
| 288 | maxNumber := 0 |
| 289 | for _, c := range containers { |
| 290 | s, ok := c.Labels[api.ContainerNumberLabel] |
| 291 | if !ok { |
| 292 | logrus.Warnf("container %s is missing %s label", c.ID, api.ContainerNumberLabel) |
| 293 | } |
| 294 | n, err := strconv.Atoi(s) |
| 295 | if err != nil { |
| 296 | logrus.Warnf("container %s has invalid %s label: %s", c.ID, api.ContainerNumberLabel, s) |
| 297 | continue |
| 298 | } |
| 299 | if n > maxNumber { |
| 300 | maxNumber = n |
| 301 | } |
| 302 | } |
| 303 | return maxNumber + 1 |
| 304 | } |
| 305 | |
| 306 | func (s *composeService) createContainer(ctx context.Context, project *types.Project, service types.ServiceConfig, |
| 307 | name string, number int, opts createOptions, |