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

Function lowestNumberedContainer

pkg/compose/pre_start.go:39–49  ·  view source on GitHub ↗

lowestNumberedContainer returns the container with the lowest com.docker.compose.container-number label, so pre_start always targets the same replica regardless of the order the daemon returned them in. Panics on an empty slice; callers must guard.

(containers Containers)

Source from the content-addressed store, hash-verified

37// same replica regardless of the order the daemon returned them in.
38// Panics on an empty slice; callers must guard.
39func lowestNumberedContainer(containers Containers) container.Summary {
40 pick := containers[0]
41 pickNum, _ := strconv.Atoi(pick.Labels[api.ContainerNumberLabel])
42 for _, ctr := range containers[1:] {
43 num, _ := strconv.Atoi(ctr.Labels[api.ContainerNumberLabel])
44 if num < pickNum {
45 pick, pickNum = ctr, num
46 }
47 }
48 return pick
49}
50
51// runPreStart executes the service's pre_start hooks sequentially, in declared
52// order. Each hook runs as an ephemeral container that shares the service

Callers 1

startServiceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected