Merge pull request #4216 from lawliet89/userns_mode

Implement `userns_mode` HostConfig for services
This commit is contained in:
Joffrey F 2016-12-19 18:12:15 -08:00 committed by GitHub
commit e6b2949edc
5 changed files with 19 additions and 1 deletions

View File

@ -88,6 +88,7 @@ DOCKER_CONFIG_KEYS = [
'stop_signal',
'tty',
'user',
'userns_mode',
'volume_driver',
'volumes',
'volumes_from',

View File

@ -217,6 +217,7 @@
}
},
"user": {"type": "string"},
"userns_mode": {"type": "string"},
"volumes": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"volume_driver": {"type": "string"},
"volumes_from": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},

View File

@ -192,6 +192,7 @@
}
},
"user": {"type": "string"},
"userns_mode": {"type": "string"},
"volumes": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"working_dir": {"type": "string"}
},

View File

@ -64,6 +64,7 @@ DOCKER_START_KEYS = [
'restart',
'security_opt',
'shm_size',
'userns_mode',
'volumes_from',
]
@ -720,7 +721,8 @@ class Service(object):
tmpfs=options.get('tmpfs'),
oom_score_adj=options.get('oom_score_adj'),
mem_swappiness=options.get('mem_swappiness'),
group_add=options.get('group_add')
group_add=options.get('group_add'),
userns_mode=options.get('userns_mode')
)
# TODO: Add as an argument to create_host_config once it's supported

View File

@ -30,6 +30,7 @@ from compose.service import ConvergencePlan
from compose.service import ConvergenceStrategy
from compose.service import NetworkMode
from compose.service import Service
from tests.integration.testcases import v2_1_only
from tests.integration.testcases import v2_only
@ -842,6 +843,18 @@ class ServiceTest(DockerClientTestCase):
container = create_and_start_container(service)
self.assertEqual(container.get('HostConfig.PidMode'), 'host')
@v2_1_only()
def test_userns_mode_none_defined(self):
service = self.create_service('web', userns_mode=None)
container = create_and_start_container(service)
self.assertEqual(container.get('HostConfig.UsernsMode'), '')
@v2_1_only()
def test_userns_mode_host(self):
service = self.create_service('web', userns_mode='host')
container = create_and_start_container(service)
self.assertEqual(container.get('HostConfig.UsernsMode'), 'host')
def test_dns_no_value(self):
service = self.create_service('web')
container = create_and_start_container(service)