mirror of https://github.com/docker/docker-py.git
Merge cf688d27b2
into db7f8b8bb6
This commit is contained in:
commit
f0768bf3a8
|
@ -570,6 +570,7 @@ class ContainerCollection(Collection):
|
|||
``["SYS_ADMIN", "MKNOD"]``.
|
||||
cap_drop (list of str): Drop kernel capabilities.
|
||||
cgroup_parent (str): Override the default parent cgroup.
|
||||
cgroup (str): Cgroup to use for the container.
|
||||
cgroupns (str): Override the default cgroup namespace mode for the
|
||||
container. One of:
|
||||
- ``private`` the container runs in its own private cgroup
|
||||
|
|
|
@ -284,7 +284,7 @@ class HostConfig(dict):
|
|||
nano_cpus=None, cpuset_mems=None, runtime=None, mounts=None,
|
||||
cpu_rt_period=None, cpu_rt_runtime=None,
|
||||
device_cgroup_rules=None, device_requests=None,
|
||||
cgroupns=None):
|
||||
cgroupns=None, cgroup=None):
|
||||
|
||||
if mem_limit is not None:
|
||||
self['Memory'] = parse_bytes(mem_limit)
|
||||
|
@ -424,6 +424,10 @@ class HostConfig(dict):
|
|||
if cgroup_parent is not None:
|
||||
self['CgroupParent'] = cgroup_parent
|
||||
|
||||
if cgroup is not None:
|
||||
if isinstance(cgroup, str):
|
||||
self['Cgroup'] = cgroup
|
||||
|
||||
if ulimits is not None:
|
||||
if not isinstance(ulimits, list):
|
||||
raise host_config_type_error('ulimits', ulimits, 'list')
|
||||
|
|
|
@ -306,6 +306,20 @@ class CreateContainerTest(BaseAPIClientTest):
|
|||
assert 'CgroupParent' in data['HostConfig']
|
||||
assert data['HostConfig']['CgroupParent'] == 'test'
|
||||
|
||||
def test_create_container_with_cgroup(self):
|
||||
self.client.create_container(
|
||||
'busybox', 'ls', host_config=self.client.create_host_config(
|
||||
cgroup='host'
|
||||
)
|
||||
)
|
||||
|
||||
args = fake_request.call_args
|
||||
assert args[0][1] == url_prefix + 'containers/create'
|
||||
data = json.loads(args[1]['data'])
|
||||
assert 'HostConfig' in data
|
||||
assert 'Cgroup' in data['HostConfig']
|
||||
assert data['HostConfig']['Cgroup'] == 'host'
|
||||
|
||||
def test_create_container_with_working_dir(self):
|
||||
self.client.create_container('busybox', 'ls',
|
||||
working_dir='/root')
|
||||
|
|
Loading…
Reference in New Issue