Nomad local development
takes 0 minutes to read
Been using nomad for a few years now at the customer I got the question couple of weeks ago from some colleagues if nomad could be used to replace docker-compose.
The reason behind the question is mainly to not vendor lock yourself for local development with the whole docker eco system.
Since I like a certain level of challenge and I do believe it's a valid use case I gave it a try.
This resulted in a nomad-local-development repository. The 2 major hurdles to take where to use one file like docker-compose.yml and dns resolving between the containers.
The first one was a rather easy one to achieve. By grouping multiple tasks into a group you can use one job file to start multiple containers. This however doesn't seems to be best practice in the field but for our use case this works quite well.
Resolving DNS between the different containers was a bit harder to tackle in regard to docker-compose where it's working out of the box. To tackle this in nomad one could use consul as a service discovery system. Consul comes by default with a DNS interface which can be used to resolve the registered tasks by nomad.
By combing this interface with DNS forwarding using dnsmasq this can be solved in a rather proper manner in this matter. When using a default nomad docker task the container will be registered with his nomad client IP in consul.
To get around this you could use the parameter address_mode = "driver"
in the service. That way the docker internal ip will be registered and used to resolve when using the consul DNS.
I used vagrant to create a sandbox for this test case to fiddle around the nomad ecosystem. How to use the setup is described in the README
Feel free to share your thoughts idea's and suggestions!