mirror of https://github.com/docker/docker-py.git
memory swap limit support
This commit is contained in:
parent
7f55a101f8
commit
7497daf34a
|
|
@ -129,7 +129,8 @@ class Client(requests.Session):
|
||||||
mem_limit=0, ports=None, environment=None, dns=None,
|
mem_limit=0, ports=None, environment=None, dns=None,
|
||||||
volumes=None, volumes_from=None,
|
volumes=None, volumes_from=None,
|
||||||
network_disabled=False, entrypoint=None,
|
network_disabled=False, entrypoint=None,
|
||||||
cpu_shares=None, working_dir=None, domainname=None):
|
cpu_shares=None, working_dir=None, domainname=None,
|
||||||
|
memswap_limit=0):
|
||||||
if isinstance(command, six.string_types):
|
if isinstance(command, six.string_types):
|
||||||
command = shlex.split(str(command))
|
command = shlex.split(str(command))
|
||||||
if isinstance(environment, dict):
|
if isinstance(environment, dict):
|
||||||
|
|
@ -192,7 +193,8 @@ class Client(requests.Session):
|
||||||
'NetworkDisabled': network_disabled,
|
'NetworkDisabled': network_disabled,
|
||||||
'Entrypoint': entrypoint,
|
'Entrypoint': entrypoint,
|
||||||
'CpuShares': cpu_shares,
|
'CpuShares': cpu_shares,
|
||||||
'WorkingDir': working_dir
|
'WorkingDir': working_dir,
|
||||||
|
'MemorySwap': memswap_limit
|
||||||
}
|
}
|
||||||
|
|
||||||
def _post_json(self, url, data, **kwargs):
|
def _post_json(self, url, data, **kwargs):
|
||||||
|
|
@ -444,12 +446,13 @@ class Client(requests.Session):
|
||||||
mem_limit=0, ports=None, environment=None, dns=None,
|
mem_limit=0, ports=None, environment=None, dns=None,
|
||||||
volumes=None, volumes_from=None,
|
volumes=None, volumes_from=None,
|
||||||
network_disabled=False, name=None, entrypoint=None,
|
network_disabled=False, name=None, entrypoint=None,
|
||||||
cpu_shares=None, working_dir=None, domainname=None):
|
cpu_shares=None, working_dir=None, domainname=None,
|
||||||
|
memswap_limit=0):
|
||||||
|
|
||||||
config = self._container_config(
|
config = self._container_config(
|
||||||
image, command, hostname, user, detach, stdin_open, tty, mem_limit,
|
image, command, hostname, user, detach, stdin_open, tty, mem_limit,
|
||||||
ports, environment, dns, volumes, volumes_from, network_disabled,
|
ports, environment, dns, volumes, volumes_from, network_disabled,
|
||||||
entrypoint, cpu_shares, working_dir, domainname
|
entrypoint, cpu_shares, working_dir, domainname, memswap_limit
|
||||||
)
|
)
|
||||||
return self.create_container_from_config(config, name)
|
return self.create_container_from_config(config, name)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStdin": false, "Memory": 0,
|
"AttachStdin": false, "Memory": 0,
|
||||||
"AttachStderr": true, "AttachStdout": true,
|
"AttachStderr": true, "AttachStdout": true,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"OpenStdin": false, "NetworkDisabled": false}'''))
|
"OpenStdin": false, "NetworkDisabled": false,
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -210,7 +211,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStderr": true,
|
"AttachStderr": true,
|
||||||
"AttachStdout": true, "OpenStdin": false,
|
"AttachStdout": true, "OpenStdin": false,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"NetworkDisabled": false}'''))
|
"NetworkDisabled": false,
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -236,7 +238,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStderr": true,
|
"AttachStderr": true,
|
||||||
"AttachStdout": true, "OpenStdin": false,
|
"AttachStdout": true, "OpenStdin": false,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"NetworkDisabled": false}'''))
|
"NetworkDisabled": false,
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -259,7 +262,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStdout": true, "OpenStdin": false,
|
"AttachStdout": true, "OpenStdin": false,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"Entrypoint": "cowsay"}'''))
|
"Entrypoint": "cowsay",
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -282,7 +286,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStdout": true, "OpenStdin": false,
|
"AttachStdout": true, "OpenStdin": false,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"CpuShares": 5}'''))
|
"CpuShares": 5,
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -305,7 +310,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStdout": true, "OpenStdin": false,
|
"AttachStdout": true, "OpenStdin": false,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"WorkingDir": "/root"}'''))
|
"WorkingDir": "/root",
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -324,7 +330,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStdin": true, "Memory": 0,
|
"AttachStdin": true, "Memory": 0,
|
||||||
"AttachStderr": true, "AttachStdout": true,
|
"AttachStderr": true, "AttachStdout": true,
|
||||||
"StdinOnce": true,
|
"StdinOnce": true,
|
||||||
"OpenStdin": true, "NetworkDisabled": false}'''))
|
"OpenStdin": true, "NetworkDisabled": false,
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
|
|
||||||
|
|
@ -358,7 +365,8 @@ class DockerClientTest(unittest.TestCase):
|
||||||
"AttachStdin": false, "Memory": 0,
|
"AttachStdin": false, "Memory": 0,
|
||||||
"AttachStderr": true, "AttachStdout": true,
|
"AttachStderr": true, "AttachStdout": true,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"OpenStdin": false, "NetworkDisabled": false}'''))
|
"OpenStdin": false, "NetworkDisabled": false,
|
||||||
|
"MemorySwap": 0}'''))
|
||||||
self.assertEqual(args[1]['headers'],
|
self.assertEqual(args[1]['headers'],
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(args[1]['params'], {'name': 'marisa-kirisame'})
|
self.assertEqual(args[1]['params'], {'name': 'marisa-kirisame'})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue