File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ def name(self):
18
18
if self .attrs .get ('Name' ) is not None :
19
19
return self .attrs ['Name' ].lstrip ('/' )
20
20
21
+ @property
22
+ def image (self ):
23
+ """
24
+ The image of the container.
25
+ """
26
+ image_id = self .attrs ['Image' ]
27
+ if image_id is None :
28
+ return None
29
+ return self .client .images .get (image_id .split (':' )[1 ])
30
+
21
31
@property
22
32
def labels (self ):
23
33
"""
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ Container objects
25
25
.. autoattribute :: short_id
26
26
.. autoattribute :: name
27
27
.. autoattribute :: status
28
+ .. autoattribute :: image
28
29
.. autoattribute :: labels
29
30
.. py :attribute :: attrs
30
31
Original file line number Diff line number Diff line change @@ -384,6 +384,11 @@ def test_get_archive(self):
384
384
container .get_archive ('foo' )
385
385
client .api .get_archive .assert_called_with (FAKE_CONTAINER_ID , 'foo' )
386
386
387
+ def test_image (self ):
388
+ client = make_fake_client ()
389
+ container = client .containers .get (FAKE_CONTAINER_ID )
390
+ assert container .image .id == FAKE_IMAGE_ID
391
+
387
392
def test_kill (self ):
388
393
client = make_fake_client ()
389
394
container = client .containers .get (FAKE_CONTAINER_ID )
You can’t perform that action at this time.
0 commit comments