docker.recipes

HashiCorp Nomad

advanced

Flexible workload orchestrator for containers and non-containerized apps.

Overview

HashiCorp Nomad is a flexible workload orchestrator that simplifies the deployment and management of containerized and non-containerized applications across diverse infrastructure environments. Unlike Kubernetes, Nomad takes a minimalist approach with a single binary deployment while supporting multiple workload types including Docker containers, virtual machines, Java applications, and raw executables. This makes it particularly valuable for organizations running mixed workloads or those seeking simpler orchestration without sacrificing powerful scheduling capabilities. This deployment runs Nomad in development mode as a single container that acts as both server and client, providing immediate access to the full Nomad experience through its web UI and API endpoints. The configuration includes Docker socket mounting to enable container orchestration and privileged access for advanced workload management. Three ports are exposed: 4646 for the HTTP API and UI, 4647 for RPC communication, and 4648 for Serf gossip protocol. This setup is ideal for developers learning Nomad, small teams prototyping workload orchestration, and organizations evaluating alternatives to more complex orchestration platforms. The development mode configuration allows immediate job submission and testing without the complexity of multi-node cluster setup, making it perfect for experimentation with Nomad's unique multi-workload capabilities and integration with other HashiCorp tools like Consul and Vault.

Key Features

  • Multi-workload support for Docker containers, VMs, Java apps, and raw executables in a single orchestrator
  • Development mode with combined server/client functionality for immediate testing and prototyping
  • Web UI accessible on port 4646 for visual job management and cluster monitoring
  • Native Docker integration with socket mounting for container orchestration capabilities
  • Built-in job scheduling with support for batch, service, and system job types
  • Datacenter federation capabilities for multi-region workload distribution
  • GPU scheduling support for machine learning and compute-intensive workloads
  • Blue/green deployment strategies with rolling updates and canary deployments

Common Use Cases

  • 1Learning and experimenting with HashiCorp Nomad's orchestration capabilities in a sandbox environment
  • 2Prototyping mixed workload deployments combining containers with legacy applications
  • 3Development environment for building and testing Nomad job specifications
  • 4Small team container orchestration without the complexity of Kubernetes
  • 5Batch processing workloads requiring flexible scheduling and resource allocation
  • 6Integration testing with other HashiCorp tools like Consul service discovery and Vault secrets management
  • 7Evaluating Nomad as an alternative to Docker Swarm or Kubernetes for specific use cases

Prerequisites

  • Minimum 512MB RAM recommended for Nomad agent and job execution
  • Docker daemon running on the host system for container workload support
  • Ports 4646, 4647, and 4648 available for Nomad HTTP, RPC, and gossip communication
  • Basic understanding of job scheduling concepts and HCL configuration syntax
  • Familiarity with Docker concepts if planning to run containerized workloads
  • Root or sudo access for privileged container operations and system resource management

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 nomad:
3 image: hashicorp/nomad:latest
4 container_name: nomad
5 restart: unless-stopped
6 command: agent -dev -bind=0.0.0.0
7 ports:
8 - "4646:4646"
9 - "4647:4647"
10 - "4648:4648"
11 volumes:
12 - nomad_data:/nomad/data
13 - /var/run/docker.sock:/var/run/docker.sock
14 cap_add:
15 - SYS_ADMIN
16 privileged: true
17
18volumes:
19 nomad_data:

.env Template

.env
1# Development mode - configure for production

Usage Notes

  1. 1Docs: https://developer.hashicorp.com/nomad/docs
  2. 2Access UI at http://localhost:4646
  3. 3Submit jobs: nomad job run myjob.nomad (or via API)
  4. 4Task drivers: Docker, exec, Java, raw_exec, QEMU
  5. 5Integrate with Consul for service discovery and Vault for secrets
  6. 6Dev mode runs as single node - use server/client separation for production

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 nomad:
5 image: hashicorp/nomad:latest
6 container_name: nomad
7 restart: unless-stopped
8 command: agent -dev -bind=0.0.0.0
9 ports:
10 - "4646:4646"
11 - "4647:4647"
12 - "4648:4648"
13 volumes:
14 - nomad_data:/nomad/data
15 - /var/run/docker.sock:/var/run/docker.sock
16 cap_add:
17 - SYS_ADMIN
18 privileged: true
19
20volumes:
21 nomad_data:
22EOF
23
24# 2. Create the .env file
25cat > .env << 'EOF'
26# Development mode - configure for production
27EOF
28
29# 3. Start the services
30docker compose up -d
31
32# 4. View logs
33docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/nomad/run | bash

Troubleshooting

  • Nomad UI not accessible: Verify port 4646 is properly exposed and not blocked by firewall rules
  • Docker driver not available error: Ensure Docker socket is mounted and Docker daemon is running on host
  • Job allocation failures: Check resource constraints and verify sufficient CPU/memory available in dev mode
  • Permission denied for system jobs: Confirm container is running with privileged flag and SYS_ADMIN capability
  • Nomad agent fails to start: Check for port conflicts on 4646-4648 and ensure no other Nomad instances running
  • Jobs stuck in pending state: Verify task driver requirements are met and check Nomad logs for scheduling conflicts

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space