Merge pull request #1580 from aanand/dont-set-network-mode-when-none-is-specified

Don't set network mode when none is specified
This commit is contained in:
Ben Firshman 2015-06-19 16:01:04 -07:00
commit 911cd60360
3 changed files with 14 additions and 2 deletions

View File

@ -188,7 +188,7 @@ class Project(object):
del service_dict['net']
else:
net = 'bridge'
net = None
return net

View File

@ -457,7 +457,7 @@ class Service(object):
def _get_net(self):
if not self.net:
return "bridge"
return None
if isinstance(self.net, Service):
containers = self.net.containers()

View File

@ -209,6 +209,18 @@ class ProjectTest(unittest.TestCase):
], None)
self.assertEqual(project.get_service('test')._get_volumes_from(), container_ids)
def test_net_unset(self):
mock_client = mock.create_autospec(docker.Client)
project = Project.from_dicts('test', [
{
'name': 'test',
'image': 'busybox:latest',
}
], mock_client)
service = project.get_service('test')
self.assertEqual(service._get_net(), None)
self.assertNotIn('NetworkMode', service._get_container_host_config({}))
def test_use_net_from_container(self):
container_id = 'aabbccddee'
container_dict = dict(Name='aaa', Id=container_id)