Skip to content

Commit 9e94070

Browse files
janLoaanand
authored andcommitted
Add support for Tmpfs declaration in Hostconfig.
This adds support for the Tmpfs option introduced in Docker 1.10. See: moby/moby#13587 Signed-off-by: Jan Losinski <[email protected]>
1 parent 7befe69 commit 9e94070

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

docker/utils/utils.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,33 @@ def convert_volume_binds(binds):
337337
return result
338338

339339

340+
def convert_tmpfs_mounts(tmpfs):
341+
if isinstance(tmpfs, dict):
342+
return tmpfs
343+
344+
if not isinstance(tmpfs, list):
345+
raise ValueError(
346+
'Tmpfs spec must be a list'
347+
)
348+
349+
result = {}
350+
for mount in tmpfs:
351+
if isinstance(mount, six.string_types):
352+
if ":" in mount:
353+
name, options = mount.split(":", 1)
354+
else:
355+
name = mount
356+
options = ""
357+
358+
else:
359+
raise ValueError(
360+
"Tmpfs spec have to be str, unicode or tuple"
361+
)
362+
363+
result[name] = options
364+
return result
365+
366+
340367
def parse_repository_tag(repo_name):
341368
parts = repo_name.rsplit('@', 1)
342369
if len(parts) == 2:
@@ -584,7 +611,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
584611
mem_limit=None, memswap_limit=None, mem_swappiness=None,
585612
cgroup_parent=None, group_add=None, cpu_quota=None,
586613
cpu_period=None, oom_kill_disable=False, shm_size=None,
587-
version=None):
614+
version=None, tmpfs=None):
588615

589616
host_config = {}
590617

@@ -751,6 +778,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
751778

752779
host_config['CpuPeriod'] = cpu_period
753780

781+
if tmpfs:
782+
host_config["Tmpfs"] = convert_tmpfs_mounts(tmpfs)
783+
754784
return host_config
755785

756786

0 commit comments

Comments
 (0)