mirror of
https://github.com/docker/compose.git
synced 2025-07-16 18:24:26 +02:00
Avoid CLI crash if image has no tags
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
e8d4616723
commit
c8ba50ff1e
@ -511,7 +511,10 @@ class TopLevelCommand(object):
|
|||||||
rows = []
|
rows = []
|
||||||
for container in containers:
|
for container in containers:
|
||||||
image_config = container.image_config
|
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]
|
image_id = image_config['Id'].split(':')[1][:12]
|
||||||
size = human_readable_file_size(image_config['Size'])
|
size = human_readable_file_size(image_config['Size'])
|
||||||
rows.append([
|
rows.append([
|
||||||
|
@ -2447,14 +2447,30 @@ class CLITestCase(DockerClientTestCase):
|
|||||||
assert 'multiplecomposefiles_another_1' in result.stdout
|
assert 'multiplecomposefiles_another_1' in result.stdout
|
||||||
assert 'multiplecomposefiles_simple_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):
|
def test_up_with_override_yaml(self):
|
||||||
self.base_dir = 'tests/fixtures/override-yaml-files'
|
self.base_dir = 'tests/fixtures/override-yaml-files'
|
||||||
self._project = get_project(self.base_dir, [])
|
self._project = get_project(self.base_dir, [])
|
||||||
self.dispatch(
|
self.dispatch(['up', '-d'], None)
|
||||||
[
|
|
||||||
'up', '-d',
|
|
||||||
],
|
|
||||||
None)
|
|
||||||
|
|
||||||
containers = self.project.containers()
|
containers = self.project.containers()
|
||||||
self.assertEqual(len(containers), 2)
|
self.assertEqual(len(containers), 2)
|
||||||
|
2
tests/fixtures/tagless-image/Dockerfile
vendored
Normal file
2
tests/fixtures/tagless-image/Dockerfile
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
FROM busybox:latest
|
||||||
|
RUN touch /blah
|
5
tests/fixtures/tagless-image/docker-compose.yml
vendored
Normal file
5
tests/fixtures/tagless-image/docker-compose.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
version: '2.3'
|
||||||
|
services:
|
||||||
|
foo:
|
||||||
|
image: ${IMAGE_ID}
|
||||||
|
command: top
|
Loading…
x
Reference in New Issue
Block a user