mirror of https://github.com/docker/compose.git
Allow options to passed to start_container
This commit is contained in:
parent
bf2505d15d
commit
c2e9353760
|
@ -29,10 +29,12 @@ class Service(object):
|
|||
while len(self.containers) > num:
|
||||
self.stop_container()
|
||||
|
||||
def start_container(self):
|
||||
def start_container(self, **override_options):
|
||||
options = dict(self.options)
|
||||
options.update(override_options)
|
||||
number = self.next_container_number()
|
||||
name = make_name(self.name, number)
|
||||
container = self.client.create_container(name=name, **self.options)
|
||||
container = self.client.create_container(name=name, **options)
|
||||
self.client.start(
|
||||
container['Id'],
|
||||
links=self._get_links(),
|
||||
|
|
|
@ -60,6 +60,11 @@ class NameTestCase(DockerClientTestCase):
|
|||
self.assertEqual(len(service.containers), 0)
|
||||
|
||||
def test_start_container_passes_through_options(self):
|
||||
db = self.create_service('db')
|
||||
db.start_container(environment={'FOO': 'BAR'})
|
||||
self.assertEqual(db.inspect()[0]['Config']['Env'], ['FOO=BAR'])
|
||||
|
||||
def test_start_container_inherits_options_from_constructor(self):
|
||||
db = self.create_service('db', environment={'FOO': 'BAR'})
|
||||
db.start_container()
|
||||
self.assertEqual(db.inspect()[0]['Config']['Env'], ['FOO=BAR'])
|
||||
|
|
Loading…
Reference in New Issue