Merge pull request #1755 from aanand/fix-container-name-one-off

Don't use custom name for one-off containers
This commit is contained in:
Aanand Prasad 2015-07-22 18:14:31 +01:00
commit fc32ccefca
2 changed files with 7 additions and 2 deletions

View File

@ -577,8 +577,10 @@ class Service(object):
for k in DOCKER_CONFIG_KEYS if k in self.options)
container_options.update(override_options)
container_options['name'] = self.custom_container_name() \
or self.get_container_name(number, one_off)
if self.custom_container_name() and not one_off:
container_options['name'] = self.custom_container_name()
else:
container_options['name'] = self.get_container_name(number, one_off)
if add_config_hash:
config_hash = self.config_hash()

View File

@ -706,6 +706,9 @@ class ServiceTest(DockerClientTestCase):
container = create_and_start_container(service)
self.assertEqual(container.name, 'my-web-container')
one_off_container = service.create_container(one_off=True)
self.assertNotEqual(one_off_container.name, 'my-web-container')
def test_log_drive_invalid(self):
service = self.create_service('web', log_driver='xxx')
self.assertRaises(ValueError, lambda: create_and_start_container(service))