Merge pull request #1846 from aanand/fix-mem-limit-options

Fix mem_limit and memswap_limit regression
(cherry picked from commit 93cc7e375130ebaaa287bb5d7e04f59bd0d6d98e)

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2015-08-11 15:59:08 +01:00
parent 5548aa5c79
commit d0792b49fa
2 changed files with 6 additions and 2 deletions

View File

@ -42,6 +42,8 @@ DOCKER_START_KEYS = [
'net',
'log_driver',
'log_opt',
'mem_limit',
'memswap_limit',
'pid',
'privileged',
'restart',
@ -684,6 +686,8 @@ class Service(object):
restart_policy=restart,
cap_add=cap_add,
cap_drop=cap_drop,
mem_limit=options.get('mem_limit'),
memswap_limit=options.get('memswap_limit'),
log_config=log_config,
extra_hosts=extra_hosts,
read_only=read_only,

View File

@ -173,8 +173,8 @@ class ServiceTest(unittest.TestCase):
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, mem_limit=1000000000, memswap_limit=2000000000)
self.mock_client.containers.return_value = []
opts = service._get_container_create_options({'some': 'overrides'}, 1)
self.assertEqual(opts['memswap_limit'], 2000000000)
self.assertEqual(opts['mem_limit'], 1000000000)
self.assertEqual(opts['host_config']['MemorySwap'], 2000000000)
self.assertEqual(opts['host_config']['Memory'], 1000000000)
def test_log_opt(self):
log_opt = {'address': 'tcp://192.168.0.42:123'}