Selaa lähdekoodia

Make inspect work for images too.

To get commands, env vars etc, we need the image's defaults to
do a diff.
tags/v0.1.1
Chris Smith 7 vuotta sitten
vanhempi
commit
fc98a924e6
1 muutettua tiedostoa jossa 7 lisäystä ja 6 poistoa
  1. 7
    6
      docker-rerun

+ 7
- 6
docker-rerun Näytä tiedosto

16
 import sys
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
     Args:
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
     Returns:
26
     Returns:
26
-        dict: Detailed information about the container.
27
+        dict: Detailed information about the  target.
27
 
28
 
28
     Raises:
29
     Raises:
29
         CalledProcessError: An error occurred talking to Docker.
30
         CalledProcessError: An error occurred talking to Docker.
30
     """
31
     """
31
     output = subprocess.check_output(['docker', 'inspect',
32
     output = subprocess.check_output(['docker', 'inspect',
32
-                                      '--type=container', container])
33
+                                      '--type=%s' % type, target])
33
     return json.loads(output.decode('utf-8'))[0]
34
     return json.loads(output.decode('utf-8'))[0]
34
 
35
 
35
 
36
 
123
                         help='Don\'t actually re-run the container, just ' \
124
                         help='Don\'t actually re-run the container, just ' \
124
                              'print what would happen.')
125
                              'print what would happen.')
125
     args = parser.parse_args()
126
     args = parser.parse_args()
126
-    container = inspect_container(args.container)
127
+    container = docker_inspect(args.container, 'container')
127
 
128
 
128
     docker_config = {'args': ['-d'], 'image': ''}
129
     docker_config = {'args': ['-d'], 'image': ''}
129
     for handler in handlers():
130
     for handler in handlers():

Loading…
Peruuta
Tallenna