mirror of
https://github.com/docker/compose.git
synced 2025-07-24 22:24:41 +02:00
Merge pull request #2189 from mnowster/support-for-cgroup_parent
Support for cgroup parent
This commit is contained in:
commit
f1e3c7b8b8
@ -21,6 +21,7 @@ from .validation import validate_top_level_object
|
|||||||
DOCKER_CONFIG_KEYS = [
|
DOCKER_CONFIG_KEYS = [
|
||||||
'cap_add',
|
'cap_add',
|
||||||
'cap_drop',
|
'cap_drop',
|
||||||
|
'cgroup_parent',
|
||||||
'command',
|
'command',
|
||||||
'cpu_shares',
|
'cpu_shares',
|
||||||
'cpuset',
|
'cpuset',
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
"build": {"type": "string"},
|
"build": {"type": "string"},
|
||||||
"cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
"cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
||||||
"cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
"cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
|
||||||
|
"cgroup_parent": {"type": "string"},
|
||||||
"command": {
|
"command": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{"type": "string"},
|
{"type": "string"},
|
||||||
|
@ -41,6 +41,7 @@ log = logging.getLogger(__name__)
|
|||||||
DOCKER_START_KEYS = [
|
DOCKER_START_KEYS = [
|
||||||
'cap_add',
|
'cap_add',
|
||||||
'cap_drop',
|
'cap_drop',
|
||||||
|
'cgroup_parent',
|
||||||
'devices',
|
'devices',
|
||||||
'dns',
|
'dns',
|
||||||
'dns_search',
|
'dns_search',
|
||||||
@ -675,6 +676,7 @@ class Service(object):
|
|||||||
read_only = options.get('read_only', None)
|
read_only = options.get('read_only', None)
|
||||||
|
|
||||||
devices = options.get('devices', None)
|
devices = options.get('devices', None)
|
||||||
|
cgroup_parent = options.get('cgroup_parent', None)
|
||||||
|
|
||||||
return self.client.create_host_config(
|
return self.client.create_host_config(
|
||||||
links=self._get_links(link_to_self=one_off),
|
links=self._get_links(link_to_self=one_off),
|
||||||
@ -696,7 +698,8 @@ class Service(object):
|
|||||||
read_only=read_only,
|
read_only=read_only,
|
||||||
pid_mode=pid,
|
pid_mode=pid,
|
||||||
security_opt=security_opt,
|
security_opt=security_opt,
|
||||||
ipc_mode=options.get('ipc')
|
ipc_mode=options.get('ipc'),
|
||||||
|
cgroup_parent=cgroup_parent
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, no_cache=False, pull=False):
|
def build(self, no_cache=False, pull=False):
|
||||||
|
@ -56,6 +56,12 @@ Override the default command.
|
|||||||
|
|
||||||
command: bundle exec thin -p 3000
|
command: bundle exec thin -p 3000
|
||||||
|
|
||||||
|
### cgroup_parent
|
||||||
|
|
||||||
|
Specify an optional parent cgroup for the container.
|
||||||
|
|
||||||
|
cgroup_parent: m-executor-abcd
|
||||||
|
|
||||||
### container_name
|
### container_name
|
||||||
|
|
||||||
Specify a custom container name, rather than a generated default name.
|
Specify a custom container name, rather than a generated default name.
|
||||||
|
@ -146,6 +146,18 @@ class ServiceTest(unittest.TestCase):
|
|||||||
2000000000
|
2000000000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_cgroup_parent(self):
|
||||||
|
self.mock_client.create_host_config.return_value = {}
|
||||||
|
|
||||||
|
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, cgroup_parent='test')
|
||||||
|
service._get_container_create_options({'some': 'overrides'}, 1)
|
||||||
|
|
||||||
|
self.assertTrue(self.mock_client.create_host_config.called)
|
||||||
|
self.assertEqual(
|
||||||
|
self.mock_client.create_host_config.call_args[1]['cgroup_parent'],
|
||||||
|
'test'
|
||||||
|
)
|
||||||
|
|
||||||
def test_log_opt(self):
|
def test_log_opt(self):
|
||||||
self.mock_client.create_host_config.return_value = {}
|
self.mock_client.create_host_config.return_value = {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user