Skip to content

Instantly share code, notes, and snippets.

@yatskevich
Created January 17, 2015 12:25
Show Gist options
  • Save yatskevich/831fa2dc3df77add1374 to your computer and use it in GitHub Desktop.
Save yatskevich/831fa2dc3df77add1374 to your computer and use it in GitHub Desktop.
Start 4 instances of Consul with Docker
# run the first server node expecting at least two more nodes to form a Consul cluster
docker run -d --name node1 -h node1 progrium/consul -server -bootstrap-expect 3
# other two nodes will join the first one using its IP (in Docker network)
JOIN_IP="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' node1)"
# run second server node
docker run -d --name node2 -h node2 progrium/consul -server -join $JOIN_IP
# run third server node
docker run -d --name node3 -h node3 progrium/consul -server -join $JOIN_IP
# run fourth *client* node, this time exposing Consul ports to the host machine
# it'll be able to communicate with the cluster but will not participate in the consensus quorum
docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp --name node4 -h node4 progrium/consul -join $JOIN_IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment