mirror of https://github.com/docker/compose.git
Allowed port range in exposed ports
Signed-off-by: Dimitar Bonev <dimitar.bonev@gmail.com>
This commit is contained in:
parent
0c626e63bc
commit
3a46abd17f
|
@ -38,7 +38,7 @@ DOCKER_CONFIG_HINTS = {
|
|||
|
||||
|
||||
VALID_NAME_CHARS = '[a-zA-Z0-9\._\-]'
|
||||
VALID_EXPOSE_FORMAT = r'^\d+(\/[a-zA-Z]+)?$'
|
||||
VALID_EXPOSE_FORMAT = r'^\d+(\-\d+)?(\/[a-zA-Z]+)?$'
|
||||
|
||||
|
||||
@FormatChecker.cls_checks(format="ports", raises=ValidationError)
|
||||
|
|
|
@ -642,6 +642,28 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertEqual(port_short, "127.0.0.1:30000")
|
||||
self.assertEqual(port_full, "127.0.0.1:30001")
|
||||
|
||||
def test_run_with_expose_ports(self):
|
||||
# create one off container
|
||||
self.base_dir = 'tests/fixtures/expose-composefile'
|
||||
self.dispatch(['run', '-d', '--service-ports', 'simple'])
|
||||
container = self.project.get_service('simple').containers(one_off=True)[0]
|
||||
|
||||
ports = container.ports
|
||||
self.assertEqual(len(ports), 9)
|
||||
# exposed ports are not mapped to host ports
|
||||
assert ports['3000/tcp'] is None
|
||||
assert ports['3001/tcp'] is None
|
||||
assert ports['3001/udp'] is None
|
||||
assert ports['3002/tcp'] is None
|
||||
assert ports['3003/tcp'] is None
|
||||
assert ports['3004/tcp'] is None
|
||||
assert ports['3005/tcp'] is None
|
||||
assert ports['3006/udp'] is None
|
||||
assert ports['3007/udp'] is None
|
||||
|
||||
# close all one off containers we just created
|
||||
container.stop()
|
||||
|
||||
def test_run_with_custom_name(self):
|
||||
self.base_dir = 'tests/fixtures/environment-composefile'
|
||||
name = 'the-container-name'
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
simple:
|
||||
image: busybox:latest
|
||||
command: top
|
||||
expose:
|
||||
- '3000'
|
||||
- '3001/tcp'
|
||||
- '3001/udp'
|
||||
- '3002-3003'
|
||||
- '3004-3005/tcp'
|
||||
- '3006-3007/udp'
|
Loading…
Reference in New Issue