Enable the Docker volume in your client config:
plugin "docker" {
config {
volumes {
enabled = true
}
}
}
Below is a job to dynamically create a CIFS Docker volume and mount it to a container:
job "cifs-example" {
datacenters = ["dc1"]
group "cache" {
network {
port "db" {
to = 6379
}
}
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
ports = ["db"]
mounts {
target = "/mount"
source = "myRedisCIFS"
volume_options {
no_copy = "false"
driver_config {
name = "local"
options {
type = "cifs"
device = "//192.168.1.123/Nomad"
o = "vers=3.0,dir_mode=0777,file_mode=0777,serverino,username=username,password=password"
}
}
}
}
}
resources {
cpu = 500
memory = 256
}
}
}
}
Please note that this job does not include any "cleanup" tasks (i.e. unmounting the volume) - it simply reproduces your original steps. However, we recommend that you include that logic if possible.