mirror of https://github.com/docker/compose.git
Print output from run
This commit is contained in:
parent
3e680a2c7a
commit
4fdd2dc077
|
@ -87,7 +87,16 @@ class TopLevelCommand(Command):
|
|||
Usage: run SERVICE COMMAND [ARGS...]
|
||||
"""
|
||||
service = self.service_collection.get(options['SERVICE'])
|
||||
service.start_container(command=[options['COMMAND']] + options['ARGS'])
|
||||
container_options = {
|
||||
'command': [options['COMMAND']] + options['ARGS'],
|
||||
}
|
||||
container = service.create_container(**container_options)
|
||||
stream = self.client.logs(container, stream=True)
|
||||
service.start_container(container, **container_options)
|
||||
for data in stream:
|
||||
if data is None:
|
||||
break
|
||||
print data
|
||||
|
||||
def start(self, options):
|
||||
"""
|
||||
|
|
|
@ -33,9 +33,14 @@ class Service(object):
|
|||
while len(self.containers) > num:
|
||||
self.stop_container()
|
||||
|
||||
def start_container(self, **override_options):
|
||||
def create_container(self, **override_options):
|
||||
container_options = self._get_container_options(override_options)
|
||||
container = self.client.create_container(**container_options)
|
||||
return self.client.create_container(**container_options)
|
||||
|
||||
def start_container(self, container=None, **override_options):
|
||||
container_options = self._get_container_options(override_options)
|
||||
if container is None:
|
||||
container = self.create_container(**override_options)
|
||||
port_bindings = {}
|
||||
for port in container_options.get('ports', []):
|
||||
port_bindings[port] = None
|
||||
|
@ -44,7 +49,7 @@ class Service(object):
|
|||
links=self._get_links(),
|
||||
port_bindings=port_bindings,
|
||||
)
|
||||
return container['Id']
|
||||
return container
|
||||
|
||||
def stop_container(self):
|
||||
container_id = self.containers[-1]['Id']
|
||||
|
|
Loading…
Reference in New Issue