@@ -154,6 +154,7 @@ type DockerDriverConfig struct {
154
154
WorkDir string `mapstructure:"work_dir"` // Working directory inside the container
155
155
Logging []DockerLoggingOpts `mapstructure:"logging"` // Logging options for syslog server
156
156
Volumes []string `mapstructure:"volumes"` // Host-Volumes to mount in, syntax: /path/to/host/directory:/destination/path/in/container
157
+ VolumeDriver string `mapstructure:"volume_driver"` // Docker volume driver used for the container's volumes
157
158
ForcePull bool `mapstructure:"force_pull"` // Always force pull before running image, useful if your tags are mutable
158
159
}
159
160
@@ -191,6 +192,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnvironment) (*Docke
191
192
dconf .Hostname = env .ReplaceEnv (dconf .Hostname )
192
193
dconf .WorkDir = env .ReplaceEnv (dconf .WorkDir )
193
194
dconf .Volumes = env .ParseAndReplace (dconf .Volumes )
195
+ dconf .VolumeDriver = env .ReplaceEnv (dconf .VolumeDriver )
194
196
dconf .DNSServers = env .ParseAndReplace (dconf .DNSServers )
195
197
dconf .DNSSearchDomains = env .ParseAndReplace (dconf .DNSSearchDomains )
196
198
dconf .LoadImages = env .ParseAndReplace (dconf .LoadImages )
@@ -388,6 +390,9 @@ func (d *DockerDriver) Validate(config map[string]interface{}) error {
388
390
"volumes" : & fields.FieldSchema {
389
391
Type : fields .TypeArray ,
390
392
},
393
+ "volume_driver" : & fields.FieldSchema {
394
+ Type : fields .TypeString ,
395
+ },
391
396
"force_pull" : & fields.FieldSchema {
392
397
Type : fields .TypeBool ,
393
398
},
@@ -695,8 +700,13 @@ func (d *DockerDriver) containerBinds(driverConfig *DockerDriverConfig, taskDir
695
700
}
696
701
697
702
// Relative paths are always allowed as they mount within a container
698
- // Expand path relative to alloc dir
699
- parts [0 ] = filepath .Join (taskDir .Dir , parts [0 ])
703
+ // When a VolumeDriver is set, we assume we receive a binding in the format volume-name:container-dest
704
+ // Otherwise, we assume we receive a relative path binding in the format relative/to/task:/also/in/container
705
+ if driverConfig .VolumeDriver == "" {
706
+ // Expand path relative to alloc dir
707
+ parts [0 ] = filepath .Join (taskDir .Dir , parts [0 ])
708
+ }
709
+
700
710
binds = append (binds , strings .Join (parts , ":" ))
701
711
}
702
712
@@ -761,6 +771,8 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas
761
771
// local directory for storage and a shared alloc directory that can be
762
772
// used to share data between different tasks in the same task group.
763
773
Binds : binds ,
774
+
775
+ VolumeDriver : driverConfig .VolumeDriver ,
764
776
}
765
777
766
778
// Windows does not support MemorySwap #2193
0 commit comments