mirror of https://github.com/docker/compose.git
Avoid CLI crash if image has no tags
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
7614becbfe
commit
d5167d5329
|
@ -511,7 +511,10 @@ class TopLevelCommand(object):
|
|||
rows = []
|
||||
for container in containers:
|
||||
image_config = container.image_config
|
||||
repo_tags = image_config['RepoTags'][0].rsplit(':', 1)
|
||||
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([
|
||||
|
|
|
@ -2447,14 +2447,30 @@ class CLITestCase(DockerClientTestCase):
|
|||
assert 'multiplecomposefiles_another_1' in result.stdout
|
||||
assert 'multiplecomposefiles_simple_1' in result.stdout
|
||||
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_images_tagless_image(self):
|
||||
self.base_dir = 'tests/fixtures/tagless-image'
|
||||
stream = self.client.build(self.base_dir, decode=True)
|
||||
img_id = None
|
||||
for data in stream:
|
||||
if 'aux' in data:
|
||||
img_id = data['aux']['ID']
|
||||
break
|
||||
if 'stream' in data and 'Successfully built' in data['stream']:
|
||||
img_id = self.client.inspect_image(data['stream'].split(' ')[2].strip())['Id']
|
||||
|
||||
assert img_id
|
||||
|
||||
os.environ['IMAGE_ID'] = img_id
|
||||
self.project.get_service('foo').create_container()
|
||||
result = self.dispatch(['images'])
|
||||
assert '<none>' in result.stdout
|
||||
assert 'taglessimage_foo_1' in result.stdout
|
||||
|
||||
def test_up_with_override_yaml(self):
|
||||
self.base_dir = 'tests/fixtures/override-yaml-files'
|
||||
self._project = get_project(self.base_dir, [])
|
||||
self.dispatch(
|
||||
[
|
||||
'up', '-d',
|
||||
],
|
||||
None)
|
||||
self.dispatch(['up', '-d'], None)
|
||||
|
||||
containers = self.project.containers()
|
||||
self.assertEqual(len(containers), 2)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
FROM busybox:latest
|
||||
RUN touch /blah
|
|
@ -0,0 +1,5 @@
|
|||
version: '2.3'
|
||||
services:
|
||||
foo:
|
||||
image: ${IMAGE_ID}
|
||||
command: top
|
Loading…
Reference in New Issue