Fix read-only usage to depend on the docker-py and docker server version

This commit is contained in:
Toshio Kuratomi 2015-09-04 15:59:19 -07:00 committed by Matt Clay
parent 13ab511642
commit b3262479e9

View file

@ -273,7 +273,7 @@ options:
read_only: read_only:
description: description:
- Mount the container's root filesystem as read only - Mount the container's root filesystem as read only
default: false default: null
aliases: [] aliases: []
version_added: "2.0" version_added: "2.0"
restart_policy: restart_policy:
@ -801,13 +801,12 @@ class DockerManager(object):
'privileged': self.module.params.get('privileged'), 'privileged': self.module.params.get('privileged'),
'links': self.links, 'links': self.links,
'network_mode': self.module.params.get('net'), 'network_mode': self.module.params.get('net'),
'read_only': self.module.params.get('read_only'),
} }
optionals = {} optionals = {}
for optional_param in ('dns', 'volumes_from', 'restart_policy', for optional_param in ('dns', 'volumes_from', 'restart_policy',
'restart_policy_retry', 'pid', 'extra_hosts', 'log_driver', 'restart_policy_retry', 'pid', 'extra_hosts', 'log_driver',
'cap_add', 'cap_drop'): 'cap_add', 'cap_drop', 'read_only'):
optionals[optional_param] = self.module.params.get(optional_param) optionals[optional_param] = self.module.params.get(optional_param)
if optionals['dns'] is not None: if optionals['dns'] is not None:
@ -850,6 +849,10 @@ class DockerManager(object):
self.ensure_capability('cap_drop') self.ensure_capability('cap_drop')
params['cap_drop'] = optionals['cap_drop'] params['cap_drop'] = optionals['cap_drop']
if optionals['read_only'] is not None:
self.ensure_capability('read_only')
params['read_only'] = optionals['read_only']
return params return params
def create_host_config(self): def create_host_config(self):
@ -1645,7 +1648,7 @@ def main():
cpu_set = dict(default=None), cpu_set = dict(default=None),
cap_add = dict(default=None, type='list'), cap_add = dict(default=None, type='list'),
cap_drop = dict(default=None, type='list'), cap_drop = dict(default=None, type='list'),
read_only = dict(default=False, type='bool'), read_only = dict(default=None, type='bool'),
), ),
required_together = ( required_together = (
['tls_client_cert', 'tls_client_key'], ['tls_client_cert', 'tls_client_key'],