Merge pull request #2830 from nubs/master

Add support for shm_size.  Fixes #2823.
This commit is contained in:
Aanand Prasad 2016-02-11 17:34:44 +00:00
commit b8f7bbb84e
7 changed files with 16 additions and 4 deletions

View File

@ -72,6 +72,7 @@ DOCKER_CONFIG_KEYS = [
'read_only', 'read_only',
'restart', 'restart',
'security_opt', 'security_opt',
'shm_size',
'stdin_open', 'stdin_open',
'stop_signal', 'stop_signal',
'tty', 'tty',

View File

@ -98,6 +98,7 @@
"read_only": {"type": "boolean"}, "read_only": {"type": "boolean"},
"restart": {"type": "string"}, "restart": {"type": "string"},
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"shm_size": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"}, "stdin_open": {"type": "boolean"},
"stop_signal": {"type": "string"}, "stop_signal": {"type": "string"},
"tty": {"type": "boolean"}, "tty": {"type": "boolean"},

View File

@ -127,6 +127,7 @@
"read_only": {"type": "boolean"}, "read_only": {"type": "boolean"},
"restart": {"type": "string"}, "restart": {"type": "string"},
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"shm_size": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"}, "stdin_open": {"type": "boolean"},
"stop_signal": {"type": "string"}, "stop_signal": {"type": "string"},
"tty": {"type": "boolean"}, "tty": {"type": "boolean"},

View File

@ -40,6 +40,7 @@ DOCKER_START_KEYS = [
'cap_add', 'cap_add',
'cap_drop', 'cap_drop',
'cgroup_parent', 'cgroup_parent',
'cpu_quota',
'devices', 'devices',
'dns', 'dns',
'dns_search', 'dns_search',
@ -54,9 +55,9 @@ DOCKER_START_KEYS = [
'pid', 'pid',
'privileged', 'privileged',
'restart', 'restart',
'volumes_from',
'security_opt', 'security_opt',
'cpu_quota', 'shm_size',
'volumes_from',
] ]
@ -654,6 +655,7 @@ class Service(object):
ipc_mode=options.get('ipc'), ipc_mode=options.get('ipc'),
cgroup_parent=options.get('cgroup_parent'), cgroup_parent=options.get('cgroup_parent'),
cpu_quota=options.get('cpu_quota'), cpu_quota=options.get('cpu_quota'),
shm_size=options.get('shm_size'),
) )
def build(self, no_cache=False, pull=False, force_rm=False): def build(self, no_cache=False, pull=False, force_rm=False):

View File

@ -591,7 +591,7 @@ specifying read-only access(``ro``) or read-write(``rw``).
> - container_name > - container_name
> - container_name:rw > - container_name:rw
### cpu\_shares, cpu\_quota, cpuset, domainname, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, privileged, read\_only, restart, stdin\_open, tty, user, working\_dir ### cpu\_shares, cpu\_quota, cpuset, domainname, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, privileged, read\_only, restart, shm\_size, stdin\_open, tty, user, working\_dir
Each of these is a single value, analogous to its Each of these is a single value, analogous to its
[docker run](https://docs.docker.com/engine/reference/run/) counterpart. [docker run](https://docs.docker.com/engine/reference/run/) counterpart.
@ -615,6 +615,7 @@ Each of these is a single value, analogous to its
restart: always restart: always
read_only: true read_only: true
shm_size: 64M
stdin_open: true stdin_open: true
tty: true tty: true

View File

@ -1,9 +1,9 @@
PyYAML==3.11 PyYAML==3.11
cached-property==1.2.0 cached-property==1.2.0
docker-py==1.7.0
dockerpty==0.4.1 dockerpty==0.4.1
docopt==0.6.1 docopt==0.6.1
enum34==1.0.4 enum34==1.0.4
git+https://github.com/docker/docker-py.git@bba8e28f822c4cd3ebe2a2ca588f41f9d7d66e26#egg=docker-py
jsonschema==2.5.1 jsonschema==2.5.1
requests==2.7.0 requests==2.7.0
six==1.7.3 six==1.7.3

View File

@ -102,6 +102,12 @@ class ServiceTest(DockerClientTestCase):
container.start() container.start()
self.assertEqual(container.get('HostConfig.CpuQuota'), 40000) self.assertEqual(container.get('HostConfig.CpuQuota'), 40000)
def test_create_container_with_shm_size(self):
service = self.create_service('db', shm_size=67108864)
container = service.create_container()
service.start_container(container)
self.assertEqual(container.get('HostConfig.ShmSize'), 67108864)
def test_create_container_with_extra_hosts_list(self): def test_create_container_with_extra_hosts_list(self):
extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229'] extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229']
service = self.create_service('db', extra_hosts=extra_hosts) service = self.create_service('db', extra_hosts=extra_hosts)