mirror of https://github.com/docker/docker-py.git
Add support for Tmpfs declaration in Hostconfig.
This adds support for the Tmpfs option introduced in Docker 1.10. See: https://github.com/docker/docker/pull/13587 Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
This commit is contained in:
parent
7befe694bd
commit
9e94070887
|
@ -337,6 +337,33 @@ def convert_volume_binds(binds):
|
|||
return result
|
||||
|
||||
|
||||
def convert_tmpfs_mounts(tmpfs):
|
||||
if isinstance(tmpfs, dict):
|
||||
return tmpfs
|
||||
|
||||
if not isinstance(tmpfs, list):
|
||||
raise ValueError(
|
||||
'Tmpfs spec must be a list'
|
||||
)
|
||||
|
||||
result = {}
|
||||
for mount in tmpfs:
|
||||
if isinstance(mount, six.string_types):
|
||||
if ":" in mount:
|
||||
name, options = mount.split(":", 1)
|
||||
else:
|
||||
name = mount
|
||||
options = ""
|
||||
|
||||
else:
|
||||
raise ValueError(
|
||||
"Tmpfs spec have to be str, unicode or tuple"
|
||||
)
|
||||
|
||||
result[name] = options
|
||||
return result
|
||||
|
||||
|
||||
def parse_repository_tag(repo_name):
|
||||
parts = repo_name.rsplit('@', 1)
|
||||
if len(parts) == 2:
|
||||
|
@ -584,7 +611,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
|||
mem_limit=None, memswap_limit=None, mem_swappiness=None,
|
||||
cgroup_parent=None, group_add=None, cpu_quota=None,
|
||||
cpu_period=None, oom_kill_disable=False, shm_size=None,
|
||||
version=None):
|
||||
version=None, tmpfs=None):
|
||||
|
||||
host_config = {}
|
||||
|
||||
|
@ -751,6 +778,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
|
|||
|
||||
host_config['CpuPeriod'] = cpu_period
|
||||
|
||||
if tmpfs:
|
||||
host_config["Tmpfs"] = convert_tmpfs_mounts(tmpfs)
|
||||
|
||||
return host_config
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue