Create a configuration file and a sample job.
docker.hcl
plugin "docker" {
config {
volumes {
enabled = true
}
}
}
example.nomad
job "example" {
datacenters = ["dc1"]
group "cache" {
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
# this is an arbitrary path on my client not exposed in any way
volumes = ["/opt/nomad/bin:/nomad"]
}
}
}
}
Start your dev agent
$ nomad agent -dev -config=docker.hcl
Run the example job, connect to the alloc, and verify that your folder mounted
[root@nomad-client-1 ~]# nomad run example.nomad
==> Monitoring evaluation "a876a981"
Evaluation triggered by job "example"
Allocation "56c7bfab" created: node "ccb65cd0", group "cache"
Evaluation within deployment: "1786f73f"
Evaluation status changed: "pending" -> "complete"
==> Evaluation "a876a981" finished with status "complete"
[root@nomad-client-1 ~]# nomad alloc status 56c
ID = 56c7bfab-d99f-15bd-45cf-ba78cc47dd21
Eval ID = a876a981
Name = example.cache[0]
Node ID = ccb65cd0
Node Name = nomad-client-1.node.consul
Job ID = example
Job Version = 0
Client Status = running
Client Description = Tasks are running
Desired Status = run
Desired Description = <none>
Created = 9s ago
Modified = 2s ago
Deployment ID = 1786f73f
Deployment Health = unset
Task "redis" is "running"
Task Resources
CPU Memory Disk Addresses
0/100 MHz 980 KiB/300 MiB 300 MiB
Task Events:
Started At = 2020-10-15T22:55:36Z
Finished At = N/A
Total Restarts = 0
Last Restart = N/A
Recent Events:
Time Type Description
2020-10-15T18:55:36-04:00 Started Task started by client
2020-10-15T18:55:28-04:00 Driver Downloading image
2020-10-15T18:55:28-04:00 Task Setup Building Task Directory
2020-10-15T18:55:28-04:00 Received Task received by client
[root@nomad-client-1 ~]# nomad alloc exec 56c sh
# cd /
# cd nomad
# ls
nomad-v0.10.4 nomad-v0.11.0-lifecycle nomad-v0.12.4
nomad-v0.10.4-spread nomad-v0.11.0-spread nomad-v0.12.4+ent
nomad-v0.10.5 nomad-v0.11.3 nomad-v0.12.4-rc1
nomad-v0.11.0-beta2 nomad-v0.12.0 nomad-v0.12.5
nomad-v0.11.0-dev nomad-v0.12.0-b1-poststop
nomad-v0.11.0-f-csi-volumes-301437e802273eabc5c72b92f23e4598e030a2ba nomad-v0.12.3
# exit