Restore container ID alias

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-02-27 13:17:28 -08:00
parent e78c0bf533
commit 07199fac37
1 changed files with 7 additions and 7 deletions

View File

@ -583,11 +583,7 @@ class Service(object):
continue
self.client.disconnect_container_from_network(container.id, network)
self.client.disconnect_container_from_network(
container.id,
network)
aliases = self._get_aliases(netdefs) if use_network_aliases else []
aliases = self._get_aliases(netdefs, container) if use_network_aliases else []
self.client.connect_container_to_network(
container.id, network,
@ -696,8 +692,12 @@ class Service(object):
numbers = [c.number for c in containers]
return 1 if not numbers else max(numbers) + 1
def _get_aliases(self, network):
return list({self.name} | set(network.get('aliases', ())))
def _get_aliases(self, network, container=None):
return list(
{self.name} |
({container.short_id} if container else set()) |
set(network.get('aliases', ()))
)
def build_default_networking_config(self):
if not self.networks: