Skip to content

Instantly share code, notes, and snippets.

View ketzacoatl's full-sized avatar

Ketzacoatl ketzacoatl

View GitHub Profile
@ketzacoatl
ketzacoatl / README.md
Last active October 1, 2020 15:17
Using a wrapper script to work around limitations in Nomad's docker driver

Overview

This gist demonstrates how to run a docker container with nomad, using a wrapper script.

Why would you want to use this?

With the wrapper, we can more easily run the container in the way we need to and without being limited by Nomad's docker driver. For example, while Nomad will have great support for volumes in the future, it has no such support right now, and the driver does not expose a config parameter to tune the volumes mounted in the docker container. This is also a great way to use consul to lookup services before starting your app, or to retrieve credentials from Vault. When running legacy applications with nomad, the wrapper script is the place to put that type of look-up logic.

We use a wrapper script and the raw_exec driver to run the container with the parameters we need.

@ketzacoatl
ketzacoatl / Main.hs
Last active August 31, 2016 05:19
is consul online?
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.Consul (getSelf, ConsulClient(..), initializeConsulClient, listKeys)
import qualified Network.Consul.Internal as I
client = initializeConsulClient "localhost" 8500 Nothing
@ketzacoatl
ketzacoatl / only-one-active-instance.py
Created September 13, 2015 16:09
Proof of Concept - Docker service orchestration via python consul-lock
import sys
from time import sleep
import consul
import consul_lock
from docker import Client
'''
This is a PoC which uses consul's locking mechanism to ensure only
one instance of the named docker container is running. Requires:
@ketzacoatl
ketzacoatl / consul-template-git.sls
Last active August 29, 2015 14:26
salt formula to build/install consul-template from source
{%- set repo_root = '/root/consul-template' %}
{%- set revision = 'v0.10.0' %}
include:
- golang
consul-template:
git.latest:
- name: https://github.com/hashicorp/consul-template