Browse Source

Use same tag as service definition

Signed-off-by: Boris HUISGEN <[email protected]>
Boris HUISGEN 7 years ago
parent
commit
a2ec572fdf
1 changed files with 12 additions and 4 deletions
  1. 12 4
      compose/cli/main.py

+ 12 - 4
compose/cli/main.py

@@ -579,10 +579,18 @@ class TopLevelCommand(object):
             rows = []
             for container in containers:
                 image_config = container.image_config
-                repo_tags = (
-                    image_config['RepoTags'][0].rsplit(':', 1) if image_config['RepoTags']
-                    else ('<none>', '<none>')
-                )
+                service = self.project.get_service(container.service)
+                if service.image_name in image_config['RepoTags']:
+                    index = image_config['RepoTags'].index(service.image_name)
+                    repo_tags = (
+                        image_config['RepoTags'][index].rsplit(':', 1) if image_config['RepoTags']
+                        else ('<none>', '<none>')
+                    )
+                else:
+                    repo_tags = (
+                        image_config['RepoTags'][0].rsplit(':', 1) if image_config['RepoTags']
+                        else ('<none>', '<none>')
+                    )
                 image_id = image_config['Id'].split(':')[1][:12]
                 size = human_readable_file_size(image_config['Size'])
                 rows.append([