-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mounted task directory volumes empty inside the container #15491
Comments
I think you're missing a |
Interesting.
If I replace the mount {
type = "bind"
source = "${NOMAD_TASK_DIR}/data"
target = "/volume_test"
} Inside my container:
|
Some more research suggests that:
But given that I haven't even mentioned mounting |
Hi @sssilver! To help explain this, let's look at the following job, which serves the job "example" {
datacenters = ["dc1"]
group "web" {
network {
mode = "bridge"
port "www" {
to = 8001
}
}
task "http" {
driver = "docker"
config {
image = "busybox:1"
command = "httpd"
args = ["-v", "-f", "-p", "8001", "-h", "/var/www"]
ports = ["www"]
volumes = [
"local:/var/www", // works: relative path
"${NOMAD_TASK_DIR}:/var/taskdir", // doesn't work: abs path
"data:/var/data", // doesn't work: wrong relative path
]
}
template {
data = "<html>hello, world</html>"
destination = "local/index.html"
}
template {
data = "<html>goodbye, world</html>"
destination = "${NOMAD_TASK_DIR}/data/goodbye.html"
}
resources {
cpu = 128
memory = 128
}
}
}
} Note that the template
So for the job above, the allocation directory looks like this:
Now let's look at our
This all results in the following mounts on the container:
The last mystery is the phantom So the template is getting rendered at ...
volumes = [
"${NOMAD_TASK_DIR}/data:/var/www",
]
}
template {
data = "<html>hello, world</html>"
destination = "${NOMAD_TASK_DIR}/data/index.html"
}
... But again, use the right paths and it shouldn't really matter. |
Looks like this has been answered as expected behavior (given the right paths), so I'm going to close this out. |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
Nomad version
Nomad v1.4.3 (f464aca)
Operating system and Environment details
Ubuntu 22.04.1 LTS
Linux ironforge 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Issue
Volumes mounting
${NOMAD_TASK_DIR}
into another directory inside the container are empty.Reproduction steps
${NOMAD_TASK_DIR}
${NOMAD_TASK_DIR}
into any path inside the container usingvolumes
ormount
stanzas intask.config
stanzaexec
into the container to observe that the directory is empty${NOMAD_TASK_DIR}
Expected Result
The rendered template is accessible inside the container in the mounted directory outside of
${NOMAD_TASK_DIR}
.Job file (if appropriate)
In Nomad:
The file is there, as expected!
Inside the Docker container:
The file isn't there although
/volume_test
exists -- unexpected!The text was updated successfully, but these errors were encountered: