DEV Community

Cover image for Deploying Docker-Compose Projects with Nomad Using raw_exec
Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on

Deploying Docker-Compose Projects with Nomad Using raw_exec

Hi there! I'm Maneshwar. Right now, I’m building LiveAPI, a first-of-its-kind tool that helps you automatically index API endpoints across all your repositories. LiveAPI makes it easier to discover, understand, and interact with APIs in large infrastructures.


TL;DR

You don’t need Nomad to parse your docker-compose.yml. Just git clone and docker-compose up --build via raw_exec. Done.

Context

I had a small project: a Go-based app that syncs data into Meilisearch. Locally, I used docker-compose to run two services:

  • Meilisearch – the search engine
  • searchsync – a Go app that reads JSON and pushes data to Meilisearch

Now I wanted to deploy this with Nomad.

The Problem

Nomad doesn’t natively support docker-compose. So I:

  1. Tried converting the compose file to Nomad jobs
  2. Got into volume mount hell
  3. Fought with constraint errors
  4. Tried building inside Docker
  5. Realized I was wasting time

So I gave up on Docker driver and used Nomad’s raw_exec instead.

The Plan

Let the raw exec driver:

  • Clone the repo
  • Run docker-compose up --build

It just works.

Prerequisites

  1. Docker Engine is installed on the target Nomad client node
  2. Docker Compose plugin installed manually:
mkdir -p ~/.docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.27.1/docker-compose-linux-x86_64 \
  -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version  # ✅ should show v2.x
Enter fullscreen mode Exit fullscreen mode
  1. Your Nomad client has access to Git (via SSH key or HTTPS token)

Nomad Job File

Here's the final working deploy.hcl:

job "searchsync-rawexec" {
  datacenters = ["dc1"]
  type        = "batch"

  group "searchsync" {
    task "bootstrap-searchsync" {
      driver = "raw_exec"

      config {
        command = "/bin/bash"
        args    = ["-c", <<EOT
cd /tmp && \
git clone [email protected]:hexmos/commons/searchsync.git && \
cd searchsync && \
docker compose up --build
EOT
        ]
      }

      constraint {
        attribute = "${node.unique.id}"
        value     = "a02c1701-53ae-1b96-5004-3d70c1227751"  # constraint to nats03 node
      }

      resources {
        cpu    = 500
        memory = 512
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Deploy It

nomad job run deploy.hcl
Enter fullscreen mode Exit fullscreen mode

Done. No image push. No registry creds. Just clone and run.

Bonus: CI/CD Step

Here's the GitLab CI step:

deploy-searchsync:
  stage: deploy-searchsync
  tags:
    - gcp-master
  script:
    - export NOMAD_ADDR="http://127.0.0.1:4646"
    - nomad job stop searchsync-rawexec || true
    - nomad job run deploy.hcl
Enter fullscreen mode Exit fullscreen mode

Conclusion

Don't overcomplicate things. If your app runs with docker-compose, just run it that way using Nomad's raw_exec. Let it do one job: boot up your service.

No variable mess. No volume hell. No hours lost converting YAML to HCL.

LiveAPI helps you get all your backend APIs documented in a few minutes.

With LiveAPI, you can generate interactive API docs that allow users to search and execute endpoints directly from the browser.

LiveAPI Demo

If you're tired of updating Swagger manually or syncing Postman collections, give it a shot.

Top comments (0)