MCPcopy
hub / github.com/docker/compose / nextContainerNumber

Function nextContainerNumber

pkg/compose/convergence.go:287–304  ·  view source on GitHub ↗
(containers []container.Summary)

Source from the content-addressed store, hash-verified

285}
286
287func 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
306func (s *composeService) createContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
307 name string, number int, opts createOptions,

Callers 1

reconcileServiceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected