|
@@ -16,20 +16,21 @@ import subprocess
|
16
|
16
|
import sys
|
17
|
17
|
|
18
|
18
|
|
19
|
|
-def inspect_container(container):
|
20
|
|
- """Uses `docker inspect` to get details about the given container.
|
|
19
|
+def docker_inspect(target, type):
|
|
20
|
+ """Uses `docker inspect` to get details about the given container or image.
|
21
|
21
|
|
22
|
22
|
Args:
|
23
|
|
- container (str): The name of the container to inspect.
|
|
23
|
+ target (str): The name of the container or image to inspect.
|
|
24
|
+ type (str): The type of object to inspect ('container' or 'image').
|
24
|
25
|
|
25
|
26
|
Returns:
|
26
|
|
- dict: Detailed information about the container.
|
|
27
|
+ dict: Detailed information about the target.
|
27
|
28
|
|
28
|
29
|
Raises:
|
29
|
30
|
CalledProcessError: An error occurred talking to Docker.
|
30
|
31
|
"""
|
31
|
32
|
output = subprocess.check_output(['docker', 'inspect',
|
32
|
|
- '--type=container', container])
|
|
33
|
+ '--type=%s' % type, target])
|
33
|
34
|
return json.loads(output.decode('utf-8'))[0]
|
34
|
35
|
|
35
|
36
|
|
|
@@ -123,7 +124,7 @@ def main():
|
123
|
124
|
help='Don\'t actually re-run the container, just ' \
|
124
|
125
|
'print what would happen.')
|
125
|
126
|
args = parser.parse_args()
|
126
|
|
- container = inspect_container(args.container)
|
|
127
|
+ container = docker_inspect(args.container, 'container')
|
127
|
128
|
|
128
|
129
|
docker_config = {'args': ['-d'], 'image': ''}
|
129
|
130
|
for handler in handlers():
|