(service *types.ServiceConfig, containersByService map[string]Containers)
| 91 | } |
| 92 | |
| 93 | func 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 | |
| 121 | func getContainerName(projectName string, service types.ServiceConfig, number int) string { |
| 122 | name := getDefaultContainerName(projectName, service.Name, strconv.Itoa(number)) |
no test coverage detected