Skip to content

Instantly share code, notes, and snippets.

@prologic
Created October 11, 2021 07:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prologic/780278c6919e490fbd9f9eb16f37d5f4 to your computer and use it in GitHub Desktop.
Save prologic/780278c6919e490fbd9f9eb16f37d5f4 to your computer and use it in GitHub Desktop.
Consul Stack (Docker Swarm)
---
version: "3.8"
services:
seed:
image: consul:latest
environment:
- "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
- "CONSUL_BIND_INTERFACE=eth0"
entrypoint:
- timeout
- -sTERM
- "300"
- 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"
server:
image: consul:latest
entrypoint:
- consul
- agent
- -server
- -data-dir=/data
- -bind={{ GetInterfaceIP "eth0" }}
- -client=0.0.0.0
- -retry-join=seed:8301
- -ui
environment:
- "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
- "CONSUL_BIND_INTERFACE=eth0"
- "CONSUL_HTTP_ADDR=0.0.0.0"
volumes:
- consul:/data
networks:
- consul
- traefik
deploy:
mode: global
placement:
constraints:
- "node.role == manager"
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.services.consul_server.loadbalancer.server.port=8500"
- "traefik.http.routers.consul_server.rule=Host(`consul.mills.io`)"
- "traefik.http.routers.consul_server.priority=2"
restart_policy:
condition: on-failure
networks:
consul:
driver: overlay
traefik:
external: true
volumes:
consul:
driver: local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment