5

Is it possible?

Here's my nomad job file

job "test-job" {
  ...
  group "test-group" {
    driver = "docker"
    config {
      image = "<image-name>"
    }
    ...
  }
}

I understand it is possible to COPY a file to a Docker image via docker build of a Dockerfile. But I want to avoid of the explicit creation of a new Docker image from the 'image-name' image.

I also understand it is possible to copy a file to a running Docker container derived from a Docker image. But since I use Nomad to roll out Docker images and populate containers it would be convenient for me if Nomad could copy (by creation on-the-fly of the new Docker layer with file copied).

So I wonder if and how it is possible?

Alexander Ites
  • 155
  • 2
  • 9

1 Answers1

7

I'm not sure I understand the question...

If you are trying to get the docker image onto the nomad agent, so nomad can run it.. Nomad will do that for you.

If you are trying to add files to a docker image after it's been built during the deploy..., Nomad has a few options.. sort of.

You can use volumes (https://www.nomadproject.io/docs/drivers/docker.html#volumes) and mount a dir with a file in it.

Alternatively you can use the artifact (https://www.nomadproject.io/docs/job-specification/artifact.html) and put it in /local (Nomad creates this folder for you), which I believe is exposed to docker containers by default.

Or, a different way, is just have the Docker container on startup just go fetch the file(s) you need. A lot of people use consul-template for that, which is now built-in to Nomad (https://www.nomadproject.io/docs/job-specification/template.html).

None of these methods are actually creating a new docker image layer however, there is no way to do that at deploy time, that should be done at build time.

zie
  • 710
  • 4
  • 7