Merge pull request #485 from squebe/run-service-ports

Added map service ports option for run command.
This commit is contained in:
Aanand Prasad 2014-12-19 14:17:57 -08:00
commit 0e172228d1
3 changed files with 49 additions and 3 deletions

View file

@ -278,6 +278,8 @@ class TopLevelCommand(Command):
-e KEY=VAL Set an environment variable (can be used multiple times)
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
--service-ports Run command with the service's ports enabled and mapped
to the host.
-T Disable pseudo-tty allocation. By default `fig run`
allocates a TTY.
"""
@ -325,11 +327,15 @@ class TopLevelCommand(Command):
insecure_registry=insecure_registry,
**container_options
)
service_ports = None
if options['--service-ports']:
service_ports = service.options['ports']
if options['-d']:
service.start_container(container, ports=None, one_off=True)
service.start_container(container, ports=service_ports, one_off=True)
print(container.name)
else:
service.start_container(container, ports=None, one_off=True)
service.start_container(container, ports=service_ports, one_off=True)
dockerpty.start(project.client, container.id, interactive=not options['-T'])
exit_code = container.wait()
if options['--rm']: