Can somebody please help me with dockerizing nomad. Do we have to write separate docker-compose files for client and server.
I am currently having a single client and single server. Here is my client.hcl -
Philosophically speaking this is not recommended; there have been various requests (GitHub issues).
Thought:
If something that controls “containers”, runs inside a container, it causes a dependency on the container runtime to be working all the time!
If you want to use a single node, the same binary can be used as a server and client.
Disclaimer: This is my personal opinion. I do not work for HashiCorp!
But seeing as how you’re using Docker Compose here, my guess is you’re just worried about having a local development environment? I mostly use Vagrant for that sort of thing, but I know a few people have hacked together something using Compose. In that case, there’s a few things to think about:
You can run the client and server in the same container in this case.
You’ll want to mount a volume for Nomad’s data_dir to persist state between container restarts.
Alternately, if you don’t need persistence, you might want to consider running Nomad in dev mode instead.
If you want to use Docker tasks, you’ll need to bind the docker socket into the Nomad container.
If you want to use raw_exec tasks, you’ll need to make sure that the binaries are accessible to the Nomad client’s container because that’s where they’ll run. (Either inside the container or maybe bind-mounted into it if they’re statically linked.)
I published a simple docker-compose.yml + Dockerfile for Nomad for working with local development workflows. Sharing here in case someone finds it useful.