Support 'expose' config option, like docker's --expose

Exposes ports to linked services without publishing them to the world.
This commit is contained in:
Aanand Prasad 2014-03-04 17:59:42 +00:00
commit 2d98071e55
3 changed files with 15 additions and 3 deletions

View file

@ -39,7 +39,7 @@ class Service(object):
if 'image' in options and 'build' in options:
raise ConfigError('Service %s has both an image and build path specified. A service can either be built to image or use an existing image, not both.' % name)
supported_options = DOCKER_CONFIG_KEYS + ['build']
supported_options = DOCKER_CONFIG_KEYS + ['build', 'expose']
for k in options:
if k not in supported_options:
@ -246,9 +246,10 @@ class Service(object):
container_options['name'] = self.next_container_name(one_off)
if 'ports' in container_options:
if 'ports' in container_options or 'expose' in self.options:
ports = []
for port in container_options['ports']:
all_ports = container_options.get('ports', []) + self.options.get('expose', [])
for port in all_ports:
port = str(port)
if ':' in port:
port = port.split(':')[-1]