Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker 我可以使用IP但不使用领事服务名?_Docker_Consul_Registrator - Fatal编程技术网

Docker 我可以使用IP但不使用领事服务名?

Docker 我可以使用IP但不使用领事服务名?,docker,consul,registrator,Docker,Consul,Registrator,我在努力自学,领事。我创建了一个停靠的领事和一个REST服务,它只返回“Hello World”,调用领事上的curl来获取信息 $ curl $(docker-machine ip):8500/v1/catalog/service/hello-server | json_pp [ { "ServiceEnableTagOverride" : false, "CreateIndex" : 87, "ModifyIndex" : 87, "Se

我在努力自学,领事。我创建了一个停靠的领事和一个REST服务,它只返回“Hello World”,调用领事上的curl来获取信息

$ 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
   }
]
ping hello服务器使我相信端点是活动的:

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
但是,当我尝试使用以下方法进行卷曲时,它将失败:

curl hello-server.service.consul:32775
然而,使用以下工作:

curl 192.168.99.100:32775
Hello World
运行docker compose时是否需要指定某种DNS地址


提前谢谢

Docker的嵌入式DNS用于容器到容器的服务发现。如果要从docker容器外部连接到已发布的端口,则需要自行设置DNS以将主机名指向docker主机。docker的嵌入式DNS用于容器到容器服务发现。如果要从docker容器外部连接到已发布的端口,则需要自行设置DNS,将主机名指向docker主机。