Skip to content

Commit

Permalink
Add support for Tmpfs declaration in Hostconfig.
Browse files Browse the repository at this point in the history
This adds support for the Tmpfs option introduced in Docker 1.10.
See: moby/moby#13587

Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
  • Loading branch information
janLo committed Feb 11, 2016
1 parent c3a66cc commit a0790b7
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion docker/utils/utils.py
Expand Up @@ -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, (str, unicode)):
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:
Expand Down Expand Up @@ -582,7 +609,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 = {}

Expand Down Expand Up @@ -755,6 +782,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


Expand Down

0 comments on commit a0790b7

Please sign in to comment.