@@ -337,6 +337,33 @@ def convert_volume_binds(binds):
337
337
return result
338
338
339
339
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
+
340
367
def parse_repository_tag (repo_name ):
341
368
parts = repo_name .rsplit ('@' , 1 )
342
369
if len (parts ) == 2 :
@@ -584,7 +611,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
584
611
mem_limit = None , memswap_limit = None , mem_swappiness = None ,
585
612
cgroup_parent = None , group_add = None , cpu_quota = None ,
586
613
cpu_period = None , oom_kill_disable = False , shm_size = None ,
587
- version = None ):
614
+ version = None , tmpfs = None ):
588
615
589
616
host_config = {}
590
617
@@ -751,6 +778,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
751
778
752
779
host_config ['CpuPeriod' ] = cpu_period
753
780
781
+ if tmpfs :
782
+ host_config ["Tmpfs" ] = convert_tmpfs_mounts (tmpfs )
783
+
754
784
return host_config
755
785
756
786
0 commit comments