mirror of https://github.com/docker/compose.git
Add support for "isolation" in config
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
f65f89ad8c
commit
dc8a39f70d
|
@ -123,6 +123,7 @@
|
|||
"hostname": {"type": "string"},
|
||||
"image": {"type": "string"},
|
||||
"ipc": {"type": "string"},
|
||||
"isolation": {"type": "string"},
|
||||
"labels": {"$ref": "#/definitions/list_or_dict"},
|
||||
"links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
||||
|
||||
|
|
|
@ -682,7 +682,7 @@ class Service(object):
|
|||
logging_dict = options.get('logging', None)
|
||||
log_config = get_log_config(logging_dict)
|
||||
|
||||
return self.client.create_host_config(
|
||||
host_config = self.client.create_host_config(
|
||||
links=self._get_links(link_to_self=one_off),
|
||||
port_bindings=build_port_bindings(options.get('ports') or []),
|
||||
binds=options.get('binds'),
|
||||
|
@ -713,6 +713,12 @@ class Service(object):
|
|||
group_add=options.get('group_add')
|
||||
)
|
||||
|
||||
# TODO: Add as an argument to create_host_config once it's supported
|
||||
# in docker-py
|
||||
host_config['Isolation'] = options.get('isolation')
|
||||
|
||||
return host_config
|
||||
|
||||
def build(self, no_cache=False, pull=False, force_rm=False):
|
||||
log.info('Building %s' % self.name)
|
||||
|
||||
|
|
|
@ -794,6 +794,49 @@ class ProjectTest(DockerClientTestCase):
|
|||
assert 'LinkLocalIPs' in ipam_config
|
||||
assert ipam_config['LinkLocalIPs'] == ['169.254.8.8']
|
||||
|
||||
@v2_1_only()
|
||||
def test_up_with_isolation(self):
|
||||
self.require_api_version('1.24')
|
||||
config_data = config.Config(
|
||||
version=V2_1,
|
||||
services=[{
|
||||
'name': 'web',
|
||||
'image': 'busybox:latest',
|
||||
'isolation': 'default'
|
||||
}],
|
||||
volumes={},
|
||||
networks={}
|
||||
)
|
||||
project = Project.from_config(
|
||||
client=self.client,
|
||||
name='composetest',
|
||||
config_data=config_data
|
||||
)
|
||||
project.up()
|
||||
service_container = project.get_service('web').containers()[0]
|
||||
assert service_container.inspect()['HostConfig']['Isolation'] == 'default'
|
||||
|
||||
@v2_1_only()
|
||||
def test_up_with_invalid_isolation(self):
|
||||
self.require_api_version('1.24')
|
||||
config_data = config.Config(
|
||||
version=V2_1,
|
||||
services=[{
|
||||
'name': 'web',
|
||||
'image': 'busybox:latest',
|
||||
'isolation': 'foobar'
|
||||
}],
|
||||
volumes={},
|
||||
networks={}
|
||||
)
|
||||
project = Project.from_config(
|
||||
client=self.client,
|
||||
name='composetest',
|
||||
config_data=config_data
|
||||
)
|
||||
with self.assertRaises(ProjectError):
|
||||
project.up()
|
||||
|
||||
@v2_only()
|
||||
def test_project_up_with_network_internal(self):
|
||||
self.require_api_version('1.23')
|
||||
|
|
|
@ -351,7 +351,7 @@ class ConfigTest(unittest.TestCase):
|
|||
base_file = config.ConfigFile(
|
||||
'base.yaml',
|
||||
{
|
||||
'version': '2.1',
|
||||
'version': V2_1,
|
||||
'services': {
|
||||
'web': {
|
||||
'image': 'example/web',
|
||||
|
@ -1330,7 +1330,7 @@ class ConfigTest(unittest.TestCase):
|
|||
'image': 'alpine',
|
||||
'group_add': ["docker", 777]
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
assert actual.services == [
|
||||
|
@ -1341,6 +1341,25 @@ class ConfigTest(unittest.TestCase):
|
|||
}
|
||||
]
|
||||
|
||||
def test_isolation_option(self):
|
||||
actual = config.load(build_config_details({
|
||||
'version': V2_1,
|
||||
'services': {
|
||||
'web': {
|
||||
'image': 'win10',
|
||||
'isolation': 'hyperv'
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
assert actual.services == [
|
||||
{
|
||||
'name': 'web',
|
||||
'image': 'win10',
|
||||
'isolation': 'hyperv',
|
||||
}
|
||||
]
|
||||
|
||||
def test_merge_service_dicts_from_files_with_extends_in_base(self):
|
||||
base = {
|
||||
'volumes': ['.:/app'],
|
||||
|
|
Loading…
Reference in New Issue