taqtiqa-mark / docker-nomad

Docker image for Nomad, based on official Consul image

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Docker Container for Nomad

This repo contains the Dockerfiles and shell scripts for my Nomad Docker image on Docker Hub, based on the official Consul image.

Make sure you check out the Nomad homepage for more information on Nomad itself.

About this Image

As this image is based on the Consul image, many of the same idioms apply to this image. The construction is similar, using Alpine Linux as the base. However, since Nomad uses cgo and normally is dynamically linked, the binary is custom built against a specific release beforehand and uploaded to the image in the place of the upstream binary.

Usage

This doc assumes you are familiar with Nomad - if you need to learn how to use it specifically, make sure you check out the homepage.

Implications of running Nomad in a Container

Keep in mind that by running this container you are, in fact, running any scheduling operations executed by this instance of Nomad within the container. This means a few things:

  • Anything run via the non-containerized drivers (ie: Fork/Exec, Java) will need to have respective dependencies baked in, ie: by building a new image off this one.
  • Containers (Docker/rkt) will need to have respective permissions delegated to the container. Docker is discussed in detail below.

Docker driver considerations

In order to use Docker properly with this container, you need to share the Docker socket with the container. Appropriate in-container permissions need to be applied too. The init script takes care of this as long as you pass in DOCKER_GID to the container with the group ID of the local host's docker group.

/tmp also needs to be shared, possibly until go-dockerclient#528 is fixed. More info. Hence, the full command for dev mode is:

docker run --net=host --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp:/tmp --env DOCKER_GID=`getent group docker | cut -d: -f3` \
  --rm vancluever/nomad

Note that if you build your own container with Docker baked in, you do not need to supply the local Docker host's GID - we assume you know what you are doing, and fail if we see a Docker group with the GID passed in.

Development Mode

Running this container with no arguments will load the container in development mode.

docker run --net=host --rm vancluever/nomad

--net=host is important to ensure that you will be able to reach respective ports from the host.

Running with Data Dir Mounted

If you are running Nomad just as an easy way to get the software, but otherwise are running off the host, you may need to mount the data directory to the host:

docker run --net=host --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp:/tmp --volume /nomad/data:/nomad/data \
  --env DOCKER_GID=`getent group docker | cut -d: -f3` \
  --rm vancluever/nomad agent AGENTOPTS

Note that AGENTOPTS here represents the agent options that would need to be added to agent, example: -server.

Coming Soon

Watch this space and the GitHub repo for more examples, such as running as a service, more details on internals, and what not.

About

Docker image for Nomad, based on official Consul image

License:Mozilla Public License 2.0


Languages

Language:Shell 83.2%Language:Makefile 16.8%