Scheduling Containers & Binaries with HashiCorp Nomad
Not every workload in your organization is a Docker container. Many teams run a mix of containerized microservices, legacy Java JARs, Go binaries, Python scripts, and batch jobs. Running a full Kubernetes cluster just to orchestrate a handful of services and standalone binaries often adds more operational overhead than value.
HashiCorp Nomad is a single-binary, lightweight workload orchestrator designed for simplicity and scale. It schedules Docker containers, standalone binaries (exec / raw_exec), Java applications, and even VMs using the exact same declarative HCL job specification—complete with automatic restarts, intelligent bin-packing, and zero-downtime rolling updates.
- How Nomad orchestrates both containers and standalone binaries with a single lightweight binary.
- Core Nomad concepts: Jobs, Task Groups, Tasks, Allocations, and Bin-Packing.
- How Nomad handles automatic restarts and zero-downtime rolling updates.
- Hands-On Lab: Start a local Nomad dev agent, submit a
.nomad.hcljob running a web service across multiple allocations, inspect placement withnomad job status, and execute a zero-downtime rolling update. - Production best practices, practice exercises, and DevOps interview questions.
1. Why Choose Nomad for Containers & Binaries?
Kubernetes is built around containers and requires a complex control plane (etcd, kube-apiserver, kube-scheduler, kube-controller-manager). Nomad ships as a single binary that acts as both server and client, uses Raft for consensus, and supports pluggable task drivers so you can run containers and native binaries side by side.
| Feature | HashiCorp Nomad | Kubernetes | Docker Swarm |
|---|---|---|---|
| Workload Types | Containers, binaries (exec), Java, QEMU |
Containers (OCI) primarily | Docker containers only |
| Operational Footprint | Single binary (~100 MB), low RAM | Multi-component control plane | Built into Docker Engine |
| Scheduling Strategy | Bin-packing or spread out of the box | Customizable scheduler | Spread by default |
| Rolling Updates | Built-in update stanza + auto-revert |
Deployment RollingUpdate | Service update-config |
2. Architecture: Bin-Packing & Zero-Downtime Rolling Updates
When you submit a job, the Nomad Server evaluates resource requirements (CPU, memory, ports) and bin-packs Allocations onto available Nomad Client nodes. During a rolling update, Nomad replaces allocations in controlled batches (max_parallel = 1), waiting for each new allocation to pass health checks before updating the next.
Nomad Scheduler: Bin-Packing & Rolling Update Wave (v1 → v2)
Nomad bin-packs both Docker containers and native binaries onto client nodes. During a rolling update, each allocation transitions from v1 (blue) to v2 (green) one at a time.
3. Hands-On Lab: Deploy & Rolling-Update a Multi-Allocation Web Service
In this lab, you will start a local Nomad development agent, deploy a web service with 3 allocations using a .nomad.hcl job file, inspect placement and resource allocation, and perform a zero-downtime rolling update.
Prerequisites
- HashiCorp Nomad 1.7+ installed (
nomad version) - Docker Engine or Docker Desktop running locally
- Two terminal windows (one for the Nomad agent, one for CLI commands)
Step 1: Start a local Nomad dev agent
In Terminal 1, launch Nomad in dev mode. This starts a single-node cluster acting as both Server and Client, with the web UI available at http://localhost:4646.
Terminal 1: Start Nomad dev agent
nomad agent -dev -bind 0.0.0.0 -network-interface='{{ GetDefaultInterfaces | attr "name" }}'
nomad agent -dev without extra flags is usually enough. Verify the agent is ready in Terminal 2 with nomad node status.Step 2: Write the Nomad job specification
Create a file named web-service.nomad.hcl. This job runs 3 allocations of a lightweight HTTP echo server, configures automatic restarts on failure, and defines a rolling update policy (max_parallel = 1).
File: web-service.nomad.hcl
job "upgradix-web" {
datacenters = ["dc1"]
type = "service"
group "web" {
count = 3
# Zero-downtime rolling update policy
update {
max_parallel = 1
min_healthy_time = "5s"
healthy_deadline = "2m"
auto_revert = true
}
# Automatic restart policy on task crash
restart {
attempts = 3
interval = "5m"
delay = "10s"
mode = "fail"
}
network {
port "http" {
to = 5678
}
}
service {
name = "upgradix-web"
provider = "nomad"
port = "http"
check {
type = "http"
path = "/"
interval = "5s"
timeout = "2s"
}
}
task "server" {
driver = "docker"
config {
image = "hashicorp/http-echo:0.2.3"
ports = ["http"]
args = [
"-listen=:5678",
"-text=Upgradix Nomad Service - Release v1.0"
]
}
resources {
cpu = 100 # MHz
memory = 64 # MB
}
}
}
}
Step 3: Plan and submit the job
In Terminal 2, validate the job, preview the scheduler plan, and submit it to Nomad.
Terminal 2: Validate, plan, and run
nomad job validate web-service.nomad.hcl
nomad job plan web-service.nomad.hcl
nomad job run web-service.nomad.hcl
Expected output
==> Monitoring evaluation "8a2f1c90"
Evaluation triggered by job "upgradix-web"
Allocation "3d19a4b2" created: node "9f81c2e4", group "web"
Allocation "7c40e1f8" created: node "9f81c2e4", group "web"
Allocation "b291d5a6" created: node "9f81c2e4", group "web"
Evaluation status changed: "pending" -> "complete"
==> Evaluation "8a2f1c90" finished with status "complete"
Step 4: Inspect placement and test the running allocations
Use nomad job status to view all 3 allocations, their placement, and their health status.
Inspect job placement
nomad job status upgradix-web
Expected output (abbreviated)
ID = upgradix-web Status = running Submit Date = 2026-11-27T19:15:10+05:30 Summary Task Group Queued Starting Running Failed Complete Lost web 0 0 3 0 0 0 Allocations ID Node ID Task Group Version Desired Status Created 3d19a4b2 9f81c2e4 web 0 run running 25s ago 7c40e1f8 9f81c2e4 web 0 run running 25s ago b291d5a6 9f81c2e4 web 0 run running 25s ago
Check the dynamically assigned port of the first allocation and curl it:
# Replace 3d19a4b2 with one of your allocation IDs
nomad alloc status 3d19a4b2 | grep -A 3 "Allocation Addresses"
Step 5: Execute a zero-downtime rolling update
Now update the -text argument in web-service.nomad.hcl from Release v1.0 to Release v2.0, then submit the updated job.
Update the task args in web-service.nomad.hcl
args = [
"-listen=:5678",
"-text=Upgradix Nomad Service - Release v2.0"
]
Run the rolling update and watch deployment progress
nomad job run web-service.nomad.hcl
nomad deployment status -monitor
Expected output
Status = successful Description = Deployment completed successfully Deployed Task Group Auto Revert Desired Placed Healthy Unhealthy web true 3 3 3 0
Because max_parallel = 1 and min_healthy_time = "5s", Nomad updated one allocation at a time, waited for its HTTP health check to pass, and only then replaced the next allocation—keeping the service online throughout the entire rollout.
4. Running a Standalone Binary Alongside Containers
If you want to schedule a compiled Go, Rust, or C# binary without wrapping it in Docker, simply switch the task driver from docker to raw_exec (or exec for chroot/cgroup isolation on Linux):
Example: Standalone binary task
task "native-worker" {
driver = "raw_exec"
config {
command = "/usr/local/bin/my-worker"
args = ["--mode=production", "--workers=4"]
}
resources {
cpu = 200
memory = 128
}
}
5. Step-by-Step Execution Breakdown
nomad job run registers your HCL spec and triggers a scheduler evaluation./ endpoint every 5 seconds.raw_exec in production: The raw_exec driver runs binaries directly on the host without filesystem isolation. Enable it only on trusted nodes, and prefer the exec driver on Linux for cgroup and chroot isolation.6. Hands-On Practice
Change count = 3 to count = 5 in web-service.nomad.hcl, run nomad job run, and verify 5 running allocations using nomad job status upgradix-web.
auto_revert)
Update the HTTP check path in web-service.nomad.hcl to an invalid port or failing command, submit the job, and watch Nomad automatically revert to the last healthy version after healthy_deadline.
Add canary = 1 and auto_promote = false to the update stanza. Submit a v3.0 update, inspect the single canary allocation, and manually promote it with nomad deployment promote <deployment-id>.
7. Interview Questions
Answer: A Job is the top-level specification of desired state. A Task Group is a set of tasks that must run together on the same client node. A Task is the individual unit of work (a container or binary). An Allocation is a single running instance of a Task Group placed on a specific node.
Answer: Bin-packing packs allocations densely onto the fewest nodes possible, leaving other nodes free for large workloads or scale-down to save cloud costs. Spread distributes allocations evenly across nodes or failure domains for maximum high availability.
Answer: Through the update stanza. By setting max_parallel, min_healthy_time, and auto_revert = true alongside service health checks, Nomad updates only a small batch of allocations at a time, verifies health before proceeding, and automatically rolls back if a new version fails.
Conclusion
HashiCorp Nomad proves that workload orchestration does not have to be heavy or complicated. With a single binary, you can schedule Docker containers and standalone executables side by side, maximize hardware efficiency with bin-packing, and ship updates safely with built-in rolling deployments and automatic rollbacks.
Try expanding this local lab by pairing Nomad with HashiCorp Consul for full service mesh routing or HashiCorp Vault for dynamic secret injection.
Official Documentation
- HashiCorp Nomad Documentation – Job Specification
- HashiCorp Nomad Documentation – Task Drivers (Docker, Exec, Raw Exec)
- HashiCorp Nomad Reference – Update Stanza & Rolling Updates
Upgradix by Shrash Studio – Learn Technology. Build Your Future.
Discussion & Comments
0No comments yet
Start the discussion above — ask a question, share a tip, or reply to a comment.