Hashicorp Nomad is a workload orchestration engine that allows you to deploy and operate workloads on multiple machines or VMs.
As such Nomad is a direct competitor to Kubernetes. In contrast to Kubernetes, Nomad allows to orchestrate not only containerized workloads, but also all kinds of non-containerized workloads like simple Linux processes, Java applications, Windows (IIS) applications, ... .
While it is flexible, it is also more simple than Kubernetes.
So recently I started looking into Nomad.
I set up Nomad on my Windows machine using chocolatey using
choco install nomad
Starting Nomad using, to setup a development agent
nomad agent -dev
While this successfully started Nomad, it did not start its Docker Task Driver, which allows to place Docker container in the Nomad Cluster. The error in the log was:
Docker is configured with Linux containers; switch to Windows containers
Searching for a solution I found this issue in the repo: Support Linux images in Docker for Windows
Basically the issue says, that the integration should work, but it is not being verified in tests. It also seems like some people got it to work while some are not.
I really don't see however, how someone could get this to run, as the fingerprinter of the docker container driver always throws an error: fingerprint.go
Some weeks later, I decided to take a different approach installing Nomad directly into the WSL Linux distribution. This allowed me to run Linux containers, while not having to launch an additional VM. These are the required steps.
Steps to get the Docker Task Driver working
- Install Docker for Desktop
- Start Docker for Desktop and make sure you have the Linux Kernel package installed; Docker will open a Microsoft website where you can find the download
- Make sure you have the WSL2 backend enabled in Docker for Desktop - Settings
- Download a Linux Distro from Microsoft Store, I have been using Ubuntu 20.04
- Install Ubuntu
- Make sure Ubuntu is the Default Linux Distro in WSL using
wsl -s Ubuntu-20.04
- Enable WSL integration for Ubuntu in the Docker for Desktop settings; you find it in Settings > Resources > WSL integration
- Install Nomad in Ubuntu (see Nomad docs)
- Start it using
nomad agent -dev --bind=0.0.0.0
- This successfully started Nomad (1.1.3 at time of writing)
- A look in the log confirmed the Docker Task Driver started
[DEBUG] client.driver_mgr: detected drivers: drivers="map[healthy:[raw_exec docker] undetected:[exec java qemu]]"
If Docker is not detected at this point check your user is in the docker group using
groups
If you cannot see the docker group, add it using
sudo usermod -aG docker $USER
Then restart WSL by exiting the shell.
Test
Finally a quick test, its very easy to test if you can deploy a container to Nomad.
nomad init
This creates a example.nomad file, that includes all configurations to deploy a Linux Redis container.
Running
nomad run example.nomad
starts the deployment and successfully starts the container:
✓ Deployment "d3935b56" successful
2021-08-04T14:13:54+02:00
ID = d3935b56
Job ID = example
Job Version = 0
Status = successful
Description = Deployment completed successfully
Deployed
Task Group Desired Placed Healthy Unhealthy Progress Deadline
cache 1 1 1 0 2021-08-04T14:23:52+02:00
Nice !!!!
Checklist
Make sure
- you have an update version of Nomad, I am using 1.1.3 at the time of writing,
- WSL2 mode is activated in Docker settings,
- the distro is activated for WSL integration in Docker settings,
- and (not WSL specific, but I always tend to forget it) add your user to the Docker group in WSL
Conclusion
After several failed attempts, using this checklist I managed to successfully start Nomad jobs on 2 different PCs.
Top comments (0)