Handle Swarm-style prefixed names in Service.containers()

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2015-01-16 16:43:59 +00:00
commit edb6b24b8f
2 changed files with 14 additions and 3 deletions

View file

@ -545,9 +545,8 @@ def get_container_name(container):
if 'Name' in container:
return container['Name']
# ps
for name in container['Names']:
if len(name.split('/')) == 2:
return name[1:]
shortest_name = min(container['Names'], key=lambda n: len(n.split('/')))
return shortest_name.split('/')[-1]
def parse_restart_spec(restart_config):