Browse Source

Support for copying commands.

tags/v0.1.1
Chris Smith 7 years ago
parent
commit
9fce2046c8
3 changed files with 12 additions and 1 deletions
  1. 1
    1
      README.md
  2. 9
    0
      docker-rerun
  3. 2
    0
      test.py

+ 1
- 1
README.md View File

@@ -26,6 +26,7 @@ option:
26 26
 
27 27
 At present docker-rerun supports a small number of commonly used arguments:
28 28
 
29
+    * Commands (trailing arguments)
29 30
     * Names (--name)
30 31
     * Networks (--net)
31 32
     * Port publications (-p)
@@ -36,7 +37,6 @@ At present docker-rerun supports a small number of commonly used arguments:
36 37
 
37 38
 Many other command line arguments:
38 39
 
39
-    * Commands
40 40
     * Environment variables
41 41
     * Labels
42 42
     * Linking and aliases

+ 9
- 0
docker-rerun View File

@@ -84,6 +84,15 @@ def handle_binds(container):
84 84
                                  lambda c: c['HostConfig']['Binds'])
85 85
 
86 86
 
87
+def handle_command(container):
88
+    """Copies the command (trailing arguments)."""
89
+    cont_cmd = container.info['Config']['Cmd']
90
+    image_cmd = container.image_info['Config']['Cmd']
91
+
92
+    if cont_cmd != image_cmd:
93
+        container.cmd = cont_cmd
94
+
95
+
87 96
 def handle_image(container):
88 97
     """Copies the image argument."""
89 98
     container.image = container.info['Config']['Image']

+ 2
- 0
test.py View File

@@ -16,6 +16,8 @@ class RerunTest(unittest.TestCase):
16 16
     def test_command_matches(self):
17 17
         commands = [
18 18
             'docker run --name=test123 -d hello-world',
19
+            'docker run --name=test123 -d hello-world:latest',
20
+            'docker run --name=test123 -d hello-world /hello world...',
19 21
             'docker run --name=test123 --restart=always -d hello-world',
20 22
             'docker run --name=test123 --restart=on-failure:10 -d hello-world',
21 23
             'docker run --name=test123 --net=host -d hello-world',

Loading…
Cancel
Save