Add a no-build option to fig up, to save time when services were already freshly built.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2014-10-26 13:23:15 -04:00
commit 3056ae4be3
5 changed files with 63 additions and 24 deletions

View file

@ -54,7 +54,7 @@ DOCKER_START_KEYS = [
'cap_add',
'cap_drop',
'dns',
'dns_search',
'dns_search',
'env_file',
'net',
'privileged',
@ -236,7 +236,7 @@ class Service(object):
return Container.create(self.client, **container_options)
raise
def recreate_containers(self, insecure_registry=False, **override_options):
def recreate_containers(self, insecure_registry=False, do_build=True, **override_options):
"""
If a container for this service doesn't exist, create and start one. If there are
any, stop them, create+start new ones, and remove the old containers.
@ -244,7 +244,10 @@ class Service(object):
containers = self.containers(stopped=True)
if not containers:
log.info("Creating %s..." % self._next_container_name(containers))
container = self.create_container(insecure_registry=insecure_registry, **override_options)
container = self.create_container(
insecure_registry=insecure_registry,
do_build=do_build,
**override_options)
self.start_container(container)
return [(None, container)]
else:
@ -283,7 +286,7 @@ class Service(object):
container.remove()
options = dict(override_options)
new_container = self.create_container(**options)
new_container = self.create_container(do_build=False, **options)
self.start_container(new_container, intermediate_container=intermediate_container)
intermediate_container.remove()
@ -330,14 +333,19 @@ class Service(object):
)
return container
def start_or_create_containers(self, insecure_registry=False, detach=False):
def start_or_create_containers(
self,
insecure_registry=False,
detach=False,
do_build=True):
containers = self.containers(stopped=True)
if not containers:
log.info("Creating %s..." % self._next_container_name(containers))
new_container = self.create_container(
insecure_registry=insecure_registry,
detach=detach
detach=detach,
do_build=do_build,
)
return [self.start_container(new_container)]
else: