Skip to content

Instantly share code, notes, and snippets.

@prologic
Created January 14, 2019 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prologic/7a2efaa659f43a0b2e4c9a46bd93e0f9 to your computer and use it in GitHub Desktop.
Save prologic/7a2efaa659f43a0b2e4c9a46bd93e0f9 to your computer and use it in GitHub Desktop.
Docker Stack for Consul
version: "3.4"
services:
seed:
image: consul:latest
environment:
- "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
- "CONSUL_BIND_INTERFACE=eth0"
entrypoint:
- timeout #this seed fires up the cluster after which it is no longer needed
- -sTERM #this is the same signal as docker would send on a scale down / stop
- -t300 #terminate after 5 mins
- consul
- agent
- -server
- -bootstrap-expect=3
- -data-dir=/tmp/consuldata
- -bind={{ GetInterfaceIP "eth0" }}
networks:
- consul
deploy:
restart_policy:
condition: none
replicas: 1
placement:
constraints:
- "node.role == manager"
cluster:
image: consul:latest
environment:
- "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
- "CONSUL_BIND_INTERFACE=eth0"
- "CONSUL_HTTP_ADDR=0.0.0.0"
entrypoint:
- consul
- agent
- -server
- -data-dir=/tmp/consul
- -bind={{ GetInterfaceIP "eth0" }}
- -client=0.0.0.0
- -retry-join=seed:8301
- -ui ##assuming you want the UI on
networks:
- "consul"
ports:
- "8600:8600"
deploy:
mode: global ##this will deploy to all nodes that
labels:
- "traefik.enable=true"
- "traefik.port=8500"
- "traefik.backend=consul"
- "traefik.docker.network=traefik"
- "traefik.frontend.rule=Host:consul.mydomain.tld"
networks:
consul:
driver: overlay
traefik:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment