From 3304c68891a16ad5d3972a95688f2c4ed426d9c6 Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Tue, 12 May 2015 11:11:36 +0100 Subject: [PATCH] Only set AttachStdin/out/err for one-off containers If we're just streaming logs from `docker-compose up`, we don't need to set AttachStdin/out/err, and doing so results in containers with different configuration depending on whether `up` or `run` were invoked with `-d` or not. Signed-off-by: Aanand Prasad --- compose/cli/main.py | 2 -- compose/project.py | 2 -- compose/service.py | 7 ++++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index 8dae737b..9379c79e 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -299,7 +299,6 @@ class TopLevelCommand(Command): start_deps=True, recreate=False, insecure_registry=insecure_registry, - detach=options['-d'] ) tty = True @@ -461,7 +460,6 @@ class TopLevelCommand(Command): start_deps=start_deps, recreate=recreate, insecure_registry=insecure_registry, - detach=detached, do_build=not options['--no-build'], ) diff --git a/compose/project.py b/compose/project.py index 8ca14481..41cd14e0 100644 --- a/compose/project.py +++ b/compose/project.py @@ -209,7 +209,6 @@ class Project(object): start_deps=True, recreate=True, insecure_registry=False, - detach=False, do_build=True): running_containers = [] for service in self.get_services(service_names, include_deps=start_deps): @@ -220,7 +219,6 @@ class Project(object): for container in create_func( insecure_registry=insecure_registry, - detach=detach, do_build=do_build): running_containers.append(container) diff --git a/compose/service.py b/compose/service.py index dc34a9bc..001d36b4 100644 --- a/compose/service.py +++ b/compose/service.py @@ -147,7 +147,7 @@ class Service(object): # Create enough containers containers = self.containers(stopped=True) while len(containers) < desired_num: - containers.append(self.create_container(detach=True)) + containers.append(self.create_container()) running_containers = [] stopped_containers = [] @@ -285,14 +285,12 @@ class Service(object): def start_or_create_containers( self, insecure_registry=False, - detach=False, do_build=True): containers = self.containers(stopped=True) if not containers: new_container = self.create_container( insecure_registry=insecure_registry, - detach=detach, do_build=do_build, ) return [self.start_container(new_container)] @@ -393,6 +391,9 @@ class Service(object): container_options['name'] = self.get_container_name(number, one_off) + if 'detach' not in container_options: + container_options['detach'] = True + # If a qualified hostname was given, split it into an # unqualified hostname and a domainname unless domainname # was also given explicitly. This matches the behavior of