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 "example" {
datacenters = ["dc1"]
group "cache" {
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
port_map { db = 6379 }
mounts = [
{
target = "/mount"
source = "myRedisCIFS"
volume_options {
no_copy = false
driver_config {
name = "local"
options = {
type = "cifs"
device = "//10.171.88.201/azu-share"
o = "vers=3.0,dir_mode=0777,file_mode=0777,serverino,username=STORAGE_USERNAME,password=XXXX"
}
}
}
}
]
}
resources { network { port "db" {} } }
service {
port = "db"
check {
name = "alive"
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
}
}
}
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.