mirror of https://github.com/docker/compose.git
Pick correct numbers for one off containers
This commit is contained in:
parent
15f12c6e2c
commit
326438b170
|
@ -108,10 +108,10 @@ class Service(object):
|
|||
bits = [self.project, self.name]
|
||||
if one_off:
|
||||
bits.append('run')
|
||||
return '_'.join(bits + [unicode(self.next_container_number())])
|
||||
return '_'.join(bits + [unicode(self.next_container_number(one_off=one_off))])
|
||||
|
||||
def next_container_number(self):
|
||||
numbers = [parse_name(c.name)[2] for c in self.containers(stopped=True)]
|
||||
def next_container_number(self, one_off=False):
|
||||
numbers = [parse_name(c.name)[2] for c in self.containers(stopped=True, one_off=one_off)]
|
||||
|
||||
if len(numbers) == 0:
|
||||
return 1
|
||||
|
|
|
@ -79,6 +79,12 @@ class ServiceTest(DockerClientTestCase):
|
|||
container = db.create_container(one_off=True)
|
||||
self.assertEqual(container.name, '/default_db_run_1')
|
||||
|
||||
def test_create_container_with_one_off_when_existing_container_is_running(self):
|
||||
db = self.create_service('db')
|
||||
db.start()
|
||||
container = db.create_container(one_off=True)
|
||||
self.assertEqual(container.name, '/default_db_run_1')
|
||||
|
||||
def test_start_container_passes_through_options(self):
|
||||
db = self.create_service('db')
|
||||
db.start_container(environment={'FOO': 'BAR'})
|
||||
|
|
Loading…
Reference in New Issue