mirror of https://github.com/docker/compose.git
Add detached mode to run
This commit is contained in:
parent
2f28265d10
commit
ea09ec672c
|
@ -111,7 +111,10 @@ class TopLevelCommand(Command):
|
||||||
"""
|
"""
|
||||||
Run a one-off command.
|
Run a one-off command.
|
||||||
|
|
||||||
Usage: run SERVICE COMMAND [ARGS...]
|
Usage: run [options] SERVICE COMMAND [ARGS...]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-d Detached mode: Run container in the background, print new container name
|
||||||
"""
|
"""
|
||||||
service = self.project.get_service(options['SERVICE'])
|
service = self.project.get_service(options['SERVICE'])
|
||||||
if service is None:
|
if service is None:
|
||||||
|
@ -120,6 +123,10 @@ class TopLevelCommand(Command):
|
||||||
'command': [options['COMMAND']] + options['ARGS'],
|
'command': [options['COMMAND']] + options['ARGS'],
|
||||||
}
|
}
|
||||||
container = service.create_container(one_off=True, **container_options)
|
container = service.create_container(one_off=True, **container_options)
|
||||||
|
if options['-d']:
|
||||||
|
service.start_container(container, ports=None)
|
||||||
|
print container.name
|
||||||
|
else:
|
||||||
stream = container.logs(stream=True)
|
stream = container.logs(stream=True)
|
||||||
service.start_container(container, ports=None)
|
service.start_container(container, ports=None)
|
||||||
for data in stream:
|
for data in stream:
|
||||||
|
@ -131,7 +138,10 @@ class TopLevelCommand(Command):
|
||||||
"""
|
"""
|
||||||
Start all services
|
Start all services
|
||||||
|
|
||||||
Usage: start [-d]
|
Usage: start [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-d Detached mode: Run containers in the background, print new container names
|
||||||
"""
|
"""
|
||||||
if options['-d']:
|
if options['-d']:
|
||||||
self.project.start()
|
self.project.start()
|
||||||
|
|
Loading…
Reference in New Issue