Merge pull request #1930 from dnephin/name_one_off_containers

Allow setting a one-off container name
This commit is contained in:
Aanand Prasad 2015-08-26 19:03:00 +01:00
commit ecd1cc31dc
5 changed files with 36 additions and 11 deletions

View file

@ -315,7 +315,7 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual('moto=bobo', container.environment['allo'])
@mock.patch('dockerpty.start')
def test_run_service_without_map_ports(self, __):
def test_run_service_without_map_ports(self, _):
# create one off container
self.command.base_dir = 'tests/fixtures/ports-composefile'
self.command.dispatch(['run', '-d', 'simple'], None)
@ -333,7 +333,7 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(port_assigned, None)
@mock.patch('dockerpty.start')
def test_run_service_with_map_ports(self, __):
def test_run_service_with_map_ports(self, _):
# create one off container
self.command.base_dir = 'tests/fixtures/ports-composefile'
@ -356,7 +356,7 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(port_range[1], "0.0.0.0:49154")
@mock.patch('dockerpty.start')
def test_run_service_with_explicitly_maped_ports(self, __):
def test_run_service_with_explicitly_maped_ports(self, _):
# create one off container
self.command.base_dir = 'tests/fixtures/ports-composefile'
@ -375,7 +375,7 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(port_full, "0.0.0.0:30001")
@mock.patch('dockerpty.start')
def test_run_service_with_explicitly_maped_ip_ports(self, __):
def test_run_service_with_explicitly_maped_ip_ports(self, _):
# create one off container
self.command.base_dir = 'tests/fixtures/ports-composefile'
@ -393,6 +393,16 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(port_short, "127.0.0.1:30000")
self.assertEqual(port_full, "127.0.0.1:30001")
@mock.patch('dockerpty.start')
def test_run_with_custom_name(self, _):
self.command.base_dir = 'tests/fixtures/environment-composefile'
name = 'the-container-name'
self.command.dispatch(['run', '--name', name, 'service'], None)
service = self.project.get_service('service')
container, = service.containers(stopped=True, one_off=True)
self.assertEqual(container.name, name)
def test_rm(self):
service = self.project.get_service('simple')
service.create_container()