mirror of https://github.com/docker/docker-py.git
api: add cgroupns option to container create (#2930)
Signed-off-by: David Otto <ottodavid@gmx.net>
This commit is contained in:
parent
1a4cacdfb6
commit
d69de54d7c
|
|
@ -553,6 +553,11 @@ class ContainerCollection(Collection):
|
||||||
``["SYS_ADMIN", "MKNOD"]``.
|
``["SYS_ADMIN", "MKNOD"]``.
|
||||||
cap_drop (list of str): Drop kernel capabilities.
|
cap_drop (list of str): Drop kernel capabilities.
|
||||||
cgroup_parent (str): Override the default parent cgroup.
|
cgroup_parent (str): Override the default parent cgroup.
|
||||||
|
cgroupns (str): Override the default cgroup namespace mode for the
|
||||||
|
container. One of:
|
||||||
|
- ``private`` the container runs in its own private cgroup
|
||||||
|
namespace.
|
||||||
|
- ``host`` use the host system's cgroup namespace.
|
||||||
cpu_count (int): Number of usable CPUs (Windows only).
|
cpu_count (int): Number of usable CPUs (Windows only).
|
||||||
cpu_percent (int): Usable percentage of the available CPUs
|
cpu_percent (int): Usable percentage of the available CPUs
|
||||||
(Windows only).
|
(Windows only).
|
||||||
|
|
@ -1002,6 +1007,7 @@ RUN_HOST_CONFIG_KWARGS = [
|
||||||
'cap_add',
|
'cap_add',
|
||||||
'cap_drop',
|
'cap_drop',
|
||||||
'cgroup_parent',
|
'cgroup_parent',
|
||||||
|
'cgroupns',
|
||||||
'cpu_count',
|
'cpu_count',
|
||||||
'cpu_percent',
|
'cpu_percent',
|
||||||
'cpu_period',
|
'cpu_period',
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,8 @@ class HostConfig(dict):
|
||||||
volume_driver=None, cpu_count=None, cpu_percent=None,
|
volume_driver=None, cpu_count=None, cpu_percent=None,
|
||||||
nano_cpus=None, cpuset_mems=None, runtime=None, mounts=None,
|
nano_cpus=None, cpuset_mems=None, runtime=None, mounts=None,
|
||||||
cpu_rt_period=None, cpu_rt_runtime=None,
|
cpu_rt_period=None, cpu_rt_runtime=None,
|
||||||
device_cgroup_rules=None, device_requests=None):
|
device_cgroup_rules=None, device_requests=None,
|
||||||
|
cgroupns=None):
|
||||||
|
|
||||||
if mem_limit is not None:
|
if mem_limit is not None:
|
||||||
self['Memory'] = parse_bytes(mem_limit)
|
self['Memory'] = parse_bytes(mem_limit)
|
||||||
|
|
@ -646,6 +647,9 @@ class HostConfig(dict):
|
||||||
req = DeviceRequest(**req)
|
req = DeviceRequest(**req)
|
||||||
self['DeviceRequests'].append(req)
|
self['DeviceRequests'].append(req)
|
||||||
|
|
||||||
|
if cgroupns:
|
||||||
|
self['CgroupnsMode'] = cgroupns
|
||||||
|
|
||||||
|
|
||||||
def host_config_type_error(param, param_value, expected):
|
def host_config_type_error(param, param_value, expected):
|
||||||
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
|
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
cap_add=['foo'],
|
cap_add=['foo'],
|
||||||
cap_drop=['bar'],
|
cap_drop=['bar'],
|
||||||
cgroup_parent='foobar',
|
cgroup_parent='foobar',
|
||||||
|
cgroupns='host',
|
||||||
cpu_period=1,
|
cpu_period=1,
|
||||||
cpu_quota=2,
|
cpu_quota=2,
|
||||||
cpu_shares=5,
|
cpu_shares=5,
|
||||||
|
|
@ -135,6 +136,7 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
'BlkioWeight': 2,
|
'BlkioWeight': 2,
|
||||||
'CapAdd': ['foo'],
|
'CapAdd': ['foo'],
|
||||||
'CapDrop': ['bar'],
|
'CapDrop': ['bar'],
|
||||||
|
'CgroupnsMode': 'host',
|
||||||
'CgroupParent': 'foobar',
|
'CgroupParent': 'foobar',
|
||||||
'CpuPeriod': 1,
|
'CpuPeriod': 1,
|
||||||
'CpuQuota': 2,
|
'CpuQuota': 2,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue