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 ?

  • Not able to execute RUN commands in Dockerfile
  • WordPress: already installed error when applying new DB
  • Extend Existing Docker Image
  • Curl connection refused between applications on Docker container
  • NPM install error running Docker on CentOS
  • Access Wildfly-Docker-Container from Apache-Docker-Container
  • General questions about docker nodemcu-build
  • mysql container broken, how to recover data?
  • Tag a docker container?
  • How to run containers in a swarm with filters using the Docker Remote API?
  • Running docker using linux kernel 4.3.0 got iptables nat error
  • docker add extract to custom directory
  • 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.