mirror of https://github.com/docker/docker-py.git
Added support for user namespace.
Signed-off-by: Srikalyan Swayampakula <srikalyansswayam@gmail.com>
This commit is contained in:
parent
94f8dd31be
commit
b5d3556bce
|
@ -620,7 +620,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
||||||
device_write_bps=None, device_read_iops=None,
|
device_write_bps=None, device_read_iops=None,
|
||||||
device_write_iops=None, oom_kill_disable=False,
|
device_write_iops=None, oom_kill_disable=False,
|
||||||
shm_size=None, version=None, tmpfs=None,
|
shm_size=None, version=None, tmpfs=None,
|
||||||
oom_score_adj=None):
|
oom_score_adj=None, userns_mode=None):
|
||||||
|
|
||||||
host_config = {}
|
host_config = {}
|
||||||
|
|
||||||
|
@ -853,6 +853,14 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
||||||
raise host_config_version_error('tmpfs', '1.22')
|
raise host_config_version_error('tmpfs', '1.22')
|
||||||
host_config["Tmpfs"] = convert_tmpfs_mounts(tmpfs)
|
host_config["Tmpfs"] = convert_tmpfs_mounts(tmpfs)
|
||||||
|
|
||||||
|
if userns_mode:
|
||||||
|
if version_lt(version, '1.23'):
|
||||||
|
raise host_config_version_error('userns_mode', '1.23')
|
||||||
|
|
||||||
|
if userns_mode != "host":
|
||||||
|
raise host_config_value_error("userns_mode", userns_mode)
|
||||||
|
host_config['UsernsMode'] = userns_mode
|
||||||
|
|
||||||
return host_config
|
return host_config
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,8 @@ for example:
|
||||||
for more information.
|
for more information.
|
||||||
* tmpfs: Temporary filesystems to mouunt. See [Using tmpfs](tmpfs.md) for more
|
* tmpfs: Temporary filesystems to mouunt. See [Using tmpfs](tmpfs.md) for more
|
||||||
information.
|
information.
|
||||||
|
* userns_mode: Sets the user namespace mode for the container when user namespace remapping option
|
||||||
|
is enabled. supported values are: host
|
||||||
|
|
||||||
**Returns** (dict) HostConfig dictionary
|
**Returns** (dict) HostConfig dictionary
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,16 @@ class HostConfigTest(base.BaseTestCase):
|
||||||
InvalidVersion, lambda: create_host_config(version='1.18.3',
|
InvalidVersion, lambda: create_host_config(version='1.18.3',
|
||||||
oom_kill_disable=True))
|
oom_kill_disable=True))
|
||||||
|
|
||||||
|
def test_create_host_config_with_userns_mode(self):
|
||||||
|
config = create_host_config(version='1.23', userns_mode='host')
|
||||||
|
self.assertEqual(config.get('UsernsMode'), 'host')
|
||||||
|
self.assertRaises(
|
||||||
|
InvalidVersion, lambda: create_host_config(version='1.22',
|
||||||
|
userns_mode='host'))
|
||||||
|
self.assertRaises(
|
||||||
|
ValueError, lambda: create_host_config(version='1.23',
|
||||||
|
userns_mode='host12'))
|
||||||
|
|
||||||
def test_create_host_config_with_oom_score_adj(self):
|
def test_create_host_config_with_oom_score_adj(self):
|
||||||
config = create_host_config(version='1.22', oom_score_adj=100)
|
config = create_host_config(version='1.22', oom_score_adj=100)
|
||||||
self.assertEqual(config.get('OomScoreAdj'), 100)
|
self.assertEqual(config.get('OomScoreAdj'), 100)
|
||||||
|
@ -602,7 +612,6 @@ class UtilsTest(base.BaseTestCase):
|
||||||
|
|
||||||
|
|
||||||
class SplitCommandTest(base.BaseTestCase):
|
class SplitCommandTest(base.BaseTestCase):
|
||||||
|
|
||||||
def test_split_command_with_unicode(self):
|
def test_split_command_with_unicode(self):
|
||||||
self.assertEqual(split_command(u'echo μμ'), ['echo', 'μμ'])
|
self.assertEqual(split_command(u'echo μμ'), ['echo', 'μμ'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue