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

Function resolveSharedNamespaces

pkg/compose/convergence.go:93–119  ·  view source on GitHub ↗
(service *types.ServiceConfig, containersByService map[string]Containers)

Source from the content-addressed store, hash-verified

91}
92
93func resolveSharedNamespaces(service *types.ServiceConfig, containersByService map[string]Containers) error {
94 if name := getDependentServiceFromMode(service.NetworkMode); name != "" {
95 dependencies := containersByService[name]
96 if len(dependencies) == 0 {
97 return fmt.Errorf("cannot share network namespace with service %s: container missing", name)
98 }
99 service.NetworkMode = types.ContainerPrefix + dependencies.sorted()[0].ID
100 }
101
102 if name := getDependentServiceFromMode(service.Ipc); name != "" {
103 dependencies := containersByService[name]
104 if len(dependencies) == 0 {
105 return fmt.Errorf("cannot share IPC namespace with service %s: container missing", name)
106 }
107 service.Ipc = types.ContainerPrefix + dependencies.sorted()[0].ID
108 }
109
110 if name := getDependentServiceFromMode(service.Pid); name != "" {
111 dependencies := containersByService[name]
112 if len(dependencies) == 0 {
113 return fmt.Errorf("cannot share PID namespace with service %s: container missing", name)
114 }
115 service.Pid = types.ContainerPrefix + dependencies.sorted()[0].ID
116 }
117
118 return nil
119}
120
121func getContainerName(projectName string, service types.ServiceConfig, number int) string {
122 name := getDefaultContainerName(projectName, service.Name, strconv.Itoa(number))

Callers 1

resolveServiceReferencesFunction · 0.85

Calls 2

sortedMethod · 0.80

Tested by

no test coverage detected