I could curl using IP but not using consul serviceName?

132 views Asked by At

I am trying to teach myself consul. I created a dockerized consul and a REST service that just returns 'Hello World', invoking curl on the consul to get the information, nets me

$ curl $(docker-machine ip):8500/v1/catalog/service/hello-server | json_pp
[
   {
      "ServiceEnableTagOverride" : false,
      "CreateIndex" : 87,
      "ModifyIndex" : 87,
      "ServiceAddress" : "192.168.99.100",
      "Node" : "bootstrap-node",
      "Address" : "192.168.99.100",
      "ServiceTags" : [],
      "ServiceID" : "5a251b3a7821:hello-server:80",
      "TaggedAddresses" : {
         "wan" : "192.168.99.100",
         "lan" : "192.168.99.100"
      },
      "NodeMeta" : {},
      "ID" : "102b597f-0b4c-4702-985e-327a5a022cc7",
      "ServiceName" : "hello-server",
      "ServicePort" : 32775
   }
]

pinging the hello-server led me to believe that the endpoint is alive:

ping -qc 1 hello-server.service.consul
PING hello-server.service.consul (62.138.239.45): 56 data bytes

--- hello-server.service.consul ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 31.035/31.035/31.035/0.000 ms

However when I try to curl using the following, it will fail:

curl hello-server.service.consul:32775

Yet, using the following works:

curl 192.168.99.100:32775
Hello World

Do I need to specify some sort of DNS address when running docker-compose?

Thanks in advance!

0

There are 0 answers