mirror of https://github.com/docker/compose.git
Fix replacing "service:x" with "container:y"
Signed-off-by: i-ky <gl.ivanovsky@gmail.com>
This commit is contained in:
parent
7cf5940f4a
commit
7f975fa40b
|
@ -126,17 +126,22 @@ func updateServices(service *types.ServiceConfig, cnts Containers) {
|
||||||
if len(cnts) == 0 {
|
if len(cnts) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cnt := cnts[0]
|
serviceName2containerID := make(map[string]string)
|
||||||
serviceName := cnt.Labels[api.ServiceLabel]
|
for _, cnt := range cnts {
|
||||||
|
serviceName := cnt.Labels[api.ServiceLabel]
|
||||||
|
if _, exists := serviceName2containerID[serviceName]; !exists {
|
||||||
|
serviceName2containerID[serviceName] = cnt.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if d := getDependentServiceFromMode(service.NetworkMode); d == serviceName {
|
if id, found := serviceName2containerID[getDependentServiceFromMode(service.NetworkMode)]; found {
|
||||||
service.NetworkMode = types.NetworkModeContainerPrefix + cnt.ID
|
service.NetworkMode = types.NetworkModeContainerPrefix + id
|
||||||
}
|
}
|
||||||
if d := getDependentServiceFromMode(service.Ipc); d == serviceName {
|
if id, found := serviceName2containerID[getDependentServiceFromMode(service.Ipc)]; found {
|
||||||
service.Ipc = types.NetworkModeContainerPrefix + cnt.ID
|
service.Ipc = types.NetworkModeContainerPrefix + id
|
||||||
}
|
}
|
||||||
if d := getDependentServiceFromMode(service.Pid); d == serviceName {
|
if id, found := serviceName2containerID[getDependentServiceFromMode(service.Pid)]; found {
|
||||||
service.Pid = types.NetworkModeContainerPrefix + cnt.ID
|
service.Pid = types.NetworkModeContainerPrefix + id
|
||||||
}
|
}
|
||||||
var links []string
|
var links []string
|
||||||
for _, serviceLink := range service.Links {
|
for _, serviceLink := range service.Links {
|
||||||
|
|
Loading…
Reference in New Issue