How to pass docker compose command to some taks in nomad

Hi! I want to download a docker compose file from my Githube repository through Nomad

I actually managed to do this, and this file was saved in the tmp folder of Nomad.

After dowmloading, I would like to pass a docker compose command to it to create the container through the downloaded file

image

But I don’t really know how to do this, could anyone advise me?

Hi @CamilaBetim :wave:

Since you are using the exec driver you will need to have docker-compose installed in the client machine that is running the task. Then, your command needs to call the docker-compose command since the YAML file is not an executable. So it would look something like this:

task "promtail" {
  driver = "exec" 

  config {
    command = "docker-compose"
    args = ["up", "repo/compose.yaml"]
  }

  artifact {
    # ...
  }
}

That being said, I would be curious to hear what’s your use case to run Docker Compose inside Nomad. While this would probably work, there are several downsides to this approach, such as harder network and storage configuration, managing the lifecycle of individual containers etc.

Would you be able to rewrite your Docker Compose to use the docker driver instead?