Merge branch 'master' of https://github.com/srikalyan/docker-py into srikalyan-master

This commit is contained in:
Joffrey F 2016-08-23 15:16:15 -07:00
commit 797f1edc20
3 changed files with 22 additions and 3 deletions

View File

@ -621,7 +621,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
device_write_iops=None, oom_kill_disable=False,
shm_size=None, sysctls=None, version=None, tmpfs=None,
oom_score_adj=None, dns_opt=None, cpu_shares=None,
cpuset_cpus=None):
cpuset_cpus=None, userns_mode=None):
host_config = {}
@ -882,6 +882,14 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
raise host_config_version_error('tmpfs', '1.22')
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

View File

@ -123,9 +123,11 @@ for example:
container process will run as.
* devices (list): Host device bindings. See [host devices](host-devices.md)
for more information.
* tmpfs: Temporary filesystems to mouunt. See [Using tmpfs](tmpfs.md) for more
* tmpfs: Temporary filesystems to mount. See [Using tmpfs](tmpfs.md) for more
information.
* sysctls (dict): Kernel parameters to set in the container.
* userns_mode (str): Sets the user namespace mode for the container when user
namespace remapping option is enabled. Supported values are: `host`
**Returns** (dict) HostConfig dictionary

View File

@ -131,6 +131,16 @@ class HostConfigTest(base.BaseTestCase):
InvalidVersion, lambda: create_host_config(version='1.18.3',
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):
config = create_host_config(version='1.22', oom_score_adj=100)
self.assertEqual(config.get('OomScoreAdj'), 100)
@ -656,7 +666,6 @@ class UtilsTest(base.BaseTestCase):
class SplitCommandTest(base.BaseTestCase):
def test_split_command_with_unicode(self):
self.assertEqual(split_command(u'echo μμ'), ['echo', 'μμ'])