Browse Source

Add option to expose ports

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

+ 2
- 0
README.md View File

@@ -51,6 +51,8 @@ the resulting container:
51 51
 
52 52
  * `--image <image>` - changes the image that will be used. You can specify
53 53
    tags (`name:tag`) or digests (`name@digest`) as with `docker run`.
54
+ * `-p <port>` or `--port <port>` - expose additional ports. Same format
55
+   as `docker run`'s `-p` option.
54 56
 
55 57
 ## What's not done yet
56 58
 

+ 9
- 0
docker-rerun View File

@@ -219,6 +219,15 @@ def modify_image(parser=None, args=None, container=None):
219 219
         container.image = args.image
220 220
 
221 221
 
222
+def modify_port_add(parser=None, args=None, container=None):
223
+   """Allows a additional ports to be exposed."""
224
+   if parser:
225
+       parser.add_argument('--port', '-p', action='append',
226
+                           help='Additional port to expose')
227
+   elif args.port:
228
+       container.args.extend(['-p=%s' % port for port in args.port])
229
+
230
+
222 231
 def functions():
223 232
     """Lists all functions defined in this module.
224 233
 

+ 8
- 0
test.py View File

@@ -58,6 +58,14 @@ def test_modifiers():
58 58
            ['docker', 'run', '--name=test123', '-d', 'hello-world'],
59 59
            ['--image', 'hello-world:latest'],
60 60
            ['docker', 'run', '--name=test123', '-d', 'hello-world:latest'])
61
+    yield (check,
62
+           ['docker', 'run', '--name=test123', '-d', 'hello-world'],
63
+           ['--port', '123:456'],
64
+           ['docker', 'run', '--name=test123', '-d', '-p=123:456', 'hello-world'])
65
+    yield (check,
66
+           ['docker', 'run', '--name=test123', '-d', 'hello-world'],
67
+           ['--port', '123:456', '-p', '80'],
68
+           ['docker', 'run', '--name=test123', '-d', '-p=123:456', '-p=80', 'hello-world'])
61 69
 
62 70
 
63 71
 @with_setup(setup_each, teardown_each)

Loading…
Cancel
Save