mirror of https://github.com/docker/compose.git
Remove override_options arg from recreate_container(s)
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
3304c68891
commit
82bc7cd5ba
|
@ -212,7 +212,7 @@ class Service(object):
|
||||||
return Container.create(self.client, **container_options)
|
return Container.create(self.client, **container_options)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def recreate_containers(self, insecure_registry=False, do_build=True, **override_options):
|
def recreate_containers(self, insecure_registry=False, do_build=True):
|
||||||
"""
|
"""
|
||||||
If a container for this service doesn't exist, create and start one. If there are
|
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.
|
any, stop them, create+start new ones, and remove the old containers.
|
||||||
|
@ -221,20 +221,16 @@ class Service(object):
|
||||||
if not containers:
|
if not containers:
|
||||||
container = self.create_container(
|
container = self.create_container(
|
||||||
insecure_registry=insecure_registry,
|
insecure_registry=insecure_registry,
|
||||||
do_build=do_build,
|
do_build=do_build)
|
||||||
**override_options)
|
|
||||||
self.start_container(container)
|
self.start_container(container)
|
||||||
return [container]
|
return [container]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
self.recreate_container(
|
self.recreate_container(c, insecure_registry=insecure_registry)
|
||||||
c,
|
|
||||||
insecure_registry=insecure_registry,
|
|
||||||
**override_options)
|
|
||||||
for c in containers
|
for c in containers
|
||||||
]
|
]
|
||||||
|
|
||||||
def recreate_container(self, container, **override_options):
|
def recreate_container(self, container, insecure_registry=False):
|
||||||
"""Recreate a container.
|
"""Recreate a container.
|
||||||
|
|
||||||
The original container is renamed to a temporary name so that data
|
The original container is renamed to a temporary name so that data
|
||||||
|
@ -257,16 +253,12 @@ class Service(object):
|
||||||
container.id,
|
container.id,
|
||||||
'%s_%s' % (container.short_id, container.name))
|
'%s_%s' % (container.short_id, container.name))
|
||||||
|
|
||||||
override_options = dict(
|
|
||||||
override_options,
|
|
||||||
environment=merge_environment(
|
|
||||||
override_options.get('environment'),
|
|
||||||
{'affinity:container': '=' + container.id}))
|
|
||||||
new_container = self.create_container(
|
new_container = self.create_container(
|
||||||
|
insecure_registry=insecure_registry,
|
||||||
do_build=False,
|
do_build=False,
|
||||||
previous_container=container,
|
previous_container=container,
|
||||||
number=container.labels.get(LABEL_CONTAINER_NUMBER),
|
number=container.labels.get(LABEL_CONTAINER_NUMBER),
|
||||||
**override_options)
|
)
|
||||||
self.start_container(new_container)
|
self.start_container(new_container)
|
||||||
container.remove()
|
container.remove()
|
||||||
return new_container
|
return new_container
|
||||||
|
@ -430,8 +422,10 @@ class Service(object):
|
||||||
self.options.get('environment'),
|
self.options.get('environment'),
|
||||||
override_options.get('environment'))
|
override_options.get('environment'))
|
||||||
|
|
||||||
if self.can_be_built():
|
if previous_container:
|
||||||
container_options['image'] = self.full_name
|
container_options['environment']['affinity:container'] = ('=' + previous_container.id)
|
||||||
|
|
||||||
|
container_options['image'] = self.image_name
|
||||||
|
|
||||||
container_options['labels'] = build_container_labels(
|
container_options['labels'] = build_container_labels(
|
||||||
container_options.get('labels', {}),
|
container_options.get('labels', {}),
|
||||||
|
|
Loading…
Reference in New Issue