Skip to content

Instantly share code, notes, and snippets.

@kelein
Last active October 25, 2017 03:20
Show Gist options
  • Save kelein/84a6f8a49fcb5af9737f13dca6e26328 to your computer and use it in GitHub Desktop.
Save kelein/84a6f8a49fcb5af9737f13dca6e26328 to your computer and use it in GitHub Desktop.
Consul Cluster on Docker
version: '2'
services:
consul_server_1:
image: consul
ports:
- '8510:8500'
- '8610:8600'
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./etc/consul.d:/etc/consul.d
command: [
'consul',
'agent',
'-server',
'-node=kallen-1',
'-client=0.0.0.0',
'-bind={{ GetInterfaceIP "eth0" }}',
'-bootstrap-expect=3',
'-data-dir=/tmp/consul/data',
'-enable-script-checks=true',
'-config-dir=/etc/consul.d',
'-retry-join=consul_server_1:8301',
'-ui'
]
hostname: 'consul_server_1'
#links:
#- consul_server2
consul_server_2:
image: consul
ports:
- '8520:8500'
- '8620:8600'
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./etc/consul.d:/etc/consul.d
command: [
'consul',
'agent',
'-server',
'-node=kallen-2',
'-client=0.0.0.0',
'-bind={{ GetInterfaceIP "eth0" }}',
'-bootstrap-expect=3',
'-data-dir=/tmp/consul/data',
'-enable-script-checks=true',
'-config-dir=/etc/consul.d',
'-retry-join=consul_server_1:8301',
#'-ui'
]
hostname: 'consul_server_2'
links:
- consul_server_1
consul_server_3:
image: consul
ports:
- '8530:8500'
- '8630:8600'
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./etc/consul.d:/etc/consul.d
command: [
'consul',
'agent',
'-server',
'-node=kallen-3',
'-client=0.0.0.0',
'-bind={{ GetInterfaceIP "eth0" }}',
'-bootstrap-expect=3',
'-data-dir=/tmp/consul/data',
'-enable-script-checks=true',
'-config-dir=/etc/consul.d',
'-retry-join=consul_server_1:8301',
#'-ui'
]
hostname: 'consul_server_3'
links:
- consul_server_1
consul_agent_1:
image: consul
ports:
- '8540:8500'
- '8640:8600'
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./etc/consul.d:/etc/consul.d
command: [
'consul',
'agent',
'-node=kallen-4',
'-client=0.0.0.0',
'-bind={{ GetInterfaceIP "eth0" }}',
'-data-dir=/tmp/consul/data',
'-enable-script-checks=true',
'-config-dir=/etc/consul.d',
'-retry-join=consul_server_1:8301',
'-ui'
]
hostname: 'consul_agent_1'
links:
- consul_server_1
consul_agent_2:
image: consul
ports:
- '8550:8500'
- '8650:8600'
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./etc/consul.d:/etc/consul.d
command: [
'consul',
'agent',
'-node=kallen-5',
'-client=0.0.0.0',
'-bind={{ GetInterfaceIP "eth0" }}',
'-data-dir=/tmp/consul/data',
'-enable-script-checks=true',
'-config-dir=/etc/consul.d',
'-retry-join=consul_server_1:8301',
'-ui'
]
hostname: 'consul_agent_2'
links:
- consul_server_1
consul_agent_3:
image: consul
ports:
- '8560:8500'
- '8660:8600'
volumes:
- /etc/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./etc/consul.d:/etc/consul.d
command: [
'consul',
'agent',
'-node=kallen-6',
'-client=0.0.0.0',
'-bind={{ GetInterfaceIP "eth0" }}',
'-data-dir=/tmp/consul/data',
'-enable-script-checks=true',
'-config-dir=/etc/consul.d',
'-retry-join=consul_server_1:8301',
'-ui'
]
hostname: 'consul_agent_3'
links:
- consul_server_1
@kelein
Copy link
Author

kelein commented Oct 23, 2017

Node      Address         Status  Type    Build  Protocol  DC   Segment
kallen-1  127.0.0.2:8301  alive   server  1.0.0  2         dc1  <all>
kallen-2  127.0.0.7:8301  alive   server  1.0.0  2         dc1  <all>
kallen-3  127.0.0.5:8301  alive   server  1.0.0  2         dc1  <all>
kallen-4  127.0.0.6:8301  alive   client  1.0.0  2         dc1  <default>
kallen-5  127.0.0.3:8301  alive   client  1.0.0  2         dc1  <default>
kallen-6  127.0.0.4:8301  alive   client  1.0.0  2         dc1  <default>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment