summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Losinski <losinski@wh2.tu-dresden.de>2016-02-11 19:16:58 +0100
committerAanand Prasad <aanand.prasad@gmail.com>2016-03-16 14:47:40 +0000
commit9e9407088786e49588c2d06dfb210d97392ea690 (patch)
tree32da7b717f84d782d643c63e0fa676f5068e7be1
parent7befe694bd21e3c54bb1d7825270ea4bd6864c13 (diff)
downloaddocker-py-9e9407088786e49588c2d06dfb210d97392ea690.tar.gz
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>
-rw-r--r--docker/utils/utils.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index d4393d5..a9cd5b7 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -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