Adding services in different consul clients running on same host

I’ve followed the section of in Testing a Consul cluster on a single host using consul. Three consul servers are successfully added and running in same host for testing purpose. Afterwards, I’ve also followed the tutorial and created a consul client node4 to expose ports. Is it possible to add more services and bind to one of those consul clients ?

  • Docker for SQL Server 2012 Container support
  • What is happening when docker-maven plugin tries to build image?
  • Dockerhub Repository Description
  • Wercker Services Not Being Linked to Main Container
  • installing ssh in the docker containers
  • `npm start` in docker ends with: Please install a supported C++11 compiler and reinstall the module
  • How to convert docker-compose setup to docker image?
  • What are different options to deliver docker images
  • Running Command “docker-compose run web …” creates a new container in Kitematic container list
  • Docker network - Why docker container responds on 127.0.0.1?
  • OpenStack and Docker
  • Where does Travis CI put my source files?
  • 2 Solutions collect form web for “Adding services in different consul clients running on same host”

    Use the new ‘swarm mode’ instead of the legacy Swarm. Swarm mode doesn’t require Consul. Service discovery and key/value store is now part of the docker daemon. Here’s how to create a 3 nodes High Available cluster (3 masters).

    1. Create three nodes

      docker-machine create --driver vmwarefusion node01
      docker-machine create --driver vmwarefusion node02
      docker-machine create --driver vmwarefusion node03
      
    2. Find the ip of node01

      docker-machine ls
      
    3. Set one as the initial swarm master

      docker $(docker-machine config node01) swarm init --advertise-addr <ip-of-node01>
      
    4. Retrieve the token to let other nodes join as master

      docker $(docker-machine config node01) swarm join-token manager
      

      This will print out something like

      docker swarm join \
      --token SWMTKN-1-0siwp7rzqeslnhuf42d16zcwodk543l99liy0wuq1mern8s8u9-8mbsrxzu9mgfw7x6ehpxh0dof \
      192.168.40.144:2377
      
    5. Add the other two nodes to the swarm as masters

      docker $(docker-machine config node02) swarm join \
      --token SWMTKN-1-0siwp7rzqeslnhuf42d16zcwodk543l99liy0wuq1mern8s8u9-8mbsrxzu9mgfw7x6ehpxh0dof \
      192.168.40.144:2377
      
      docker $(docker-machine config node03) swarm join \
      --token SWMTKN-1-0siwp7rzqeslnhuf42d16zcwodk543l99liy0wuq1mern8s8u9-8mbsrxzu9mgfw7x6ehpxh0dof \
      192.168.40.144:2377
      
    6. Examine the swarm

      docker node ls
      

    You should now be able to shutdown the leader node and see another pick up as manager.

    Best practice for Consul, is to run consul one per HOST, and when you want to talk to consul, you always talk locally. In general, everything 1 consul node knows, every other consul node also knows. So you can just talk to your localhost consul (127.0.0.1:8500) and do everything you need to do. When you add services, you add them to the local consul node that has the service’s process on it. There are projects like Registrator (https://github.com/gliderlabs/registrator) That will automatically add services from running docker containers, which makes life easier.

    Overall, welcome to Consul, it’s great stuff!

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.