diff --git a/plum/service.py b/plum/service.py index 8e7660a11..254bc9d99 100644 --- a/plum/service.py +++ b/plum/service.py @@ -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(), diff --git a/plum/tests/service_test.py b/plum/tests/service_test.py index 7bd0e0b23..ed2c3db78 100644 --- a/plum/tests/service_test.py +++ b/plum/tests/service_test.py @@ -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'])