Is it not possible to load a Docker image from the alloc/
directory?
I have a Docker image archive that I retrieve in a separate task and store in the alloc/
directory. Then I try to load it:
task "app" {
driver = "docker"
config {
load = "${NOMAD_ALLOC_DIR}/docker-image.tar"
image = "docker-image"
}
}
Which gives me:
unable to open image archive:
open /var/lib/nomad/alloc/4544-snip-c4df/app/local/alloc/docker-image.tar:
no such file or directory
No matter what I specify, Nomad (or Docker) always tries to load from /taskname/local/
.
Does the load
config option not have access to the alloc
directory?
If I use the volumes
config option, could I bind a path that the Docker container can use? I have tried this already, and it does not seem to work.
Is there any other way to get a local file into a Docker container? Perhaps from a pre-start task? The artifact
stanza does not seem built for accessing local files.
I found an example of traversing parent directories in order to reach into the alloc/
directory.
task "app" {
driver = "docker"
config {
load = "../../${NOMAD_ALLOC_DIR}/docker-image.tar"
image = "docker-image"
}
}
This does seem to at least move me past one error, and into another:
open /var/lib/docker/tmp/docker-import-018997931/bin/json: no such file or directory
This may be just a problem with the image. I will need to verify the image is valid.
Yes, there was a problem with the image also. I rebuilt the image and then had a problem addressing the image as docker-image
. That docker-image
was just the name of the archive file. For the image
config option I needed to specify the name that the image had been tagged with. I specified that and now we are golden.