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 ?

  • How to set up Hadoop in Docker Swarm?
  • Replication of MySQL database between docker swarm clusters
  • mvn jetty:run-forked inside a docker container?
  • How to share data between the docker container and the host?
  • How to copy files from an absolute path to docker image using docker maven plugin
  • How to restart tcserver instance within docker?
  • Creating Docker Base Image from a Dockerfile?
  • using docker stack deploy on oracle linux 6
  • docker-compose: where to store configuration for services?
  • Debug on Docker throws an error
  • Ambari 2.2 - exiting with non-zero status code on Ubuntu 14.04 Docker container
  • Improving Docker security
  • 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 \
    5. Add the other two nodes to the swarm as masters

      docker $(docker-machine config node02) swarm join \
      --token SWMTKN-1-0siwp7rzqeslnhuf42d16zcwodk543l99liy0wuq1mern8s8u9-8mbsrxzu9mgfw7x6ehpxh0dof \
      docker $(docker-machine config node03) swarm join \
      --token SWMTKN-1-0siwp7rzqeslnhuf42d16zcwodk543l99liy0wuq1mern8s8u9-8mbsrxzu9mgfw7x6ehpxh0dof \
    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 ( 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 ( 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.