@@ -442,6 +442,7 @@ def _default_name_template(self):
442
442
)
443
443
444
444
mounts = List (
445
+ Dict (),
445
446
config = True ,
446
447
help = dedent (
447
448
"""
@@ -894,24 +895,6 @@ def volume_binds(self):
894
895
read_only_volumes .update (self .read_only_volumes )
895
896
return self ._volumes_to_binds (read_only_volumes , binds , mode = "ro" )
896
897
897
- @property
898
- def mount_binds (self ):
899
- """
900
- A different way of specifying docker volumes using more advanced spec.
901
- Converts mounts list of dict to a list of docker.types.Mount
902
- """
903
-
904
- def _fmt (v ):
905
- return self .format_volume_name (v , self )
906
-
907
- mounts = []
908
- for mount in self .mounts :
909
- args = dict (mount )
910
- args ["source" ] = _fmt (mount ["source" ])
911
- args ["target" ] = _fmt (mount ["target" ])
912
- mounts .append (Mount (** args ))
913
- return mounts
914
-
915
898
_escaped_name = None
916
899
917
900
@property
@@ -1184,12 +1167,24 @@ async def create_object(self):
1184
1167
1185
1168
_deep_merge (create_kwargs , extra_create_kwargs )
1186
1169
1170
+ # Make a list of mount objects if present, formatting strings but passing through everything else
1171
+ mount_binds = [
1172
+ Mount (
1173
+ ** {
1174
+ k : self .format_volume_name (v , self ) if isinstance (v , str ) else v
1175
+ for k , v in mount .items ()
1176
+ }
1177
+ )
1178
+ for mount in self .mounts
1179
+ ]
1180
+
1187
1181
# build the dictionary of keyword arguments for host_config
1182
+
1188
1183
host_config = dict (
1189
1184
auto_remove = self .remove ,
1190
1185
binds = self .volume_binds ,
1191
1186
links = self .links ,
1192
- mounts = self . mount_binds ,
1187
+ mounts = mount_binds ,
1193
1188
)
1194
1189
1195
1190
if getattr (self , "mem_limit" , None ) is not None :
0 commit comments