领事不公开发布注册的服务地址和端口

时间:2018-11-14 10:21:36

标签: docker consul

我有一个将其地址注册到Consul的节点服务器。两者都在docker容器中运行。

consul.deregister();

const registration = { address: CONSUL_HOST || '127.0.0.1',
 port: parseInt(process.env.PORT, 10) || 3000 };


console.log(registration);
//logs correct host and port from within its container

setInterval(() =>
  consul.register(registration),
30000);
然后

consul注册该服务。以下是来自consul容器的节点服务响应。

[
    {
        "ID": "<-- id -->",
        "Node": "consul",
        "Address": "127.0.0.1",
        "Datacenter": "dc1",
        "TaggedAddresses": {
            "lan": "127.0.0.1",
            "wan": "127.0.0.1"
        },
        "NodeMeta": {
            "consul-network-segment": ""
        },
        "ServiceID": "my_portal",
        "ServiceName": "my_portal",
        "ServiceTags": [],
        "ServiceAddress": "", ## <--- ?
        "ServiceMeta": {},
        "ServicePort": 0, ## <--- ?
        "ServiceEnableTagOverride": false,
        "CreateIndex": 12,
        "ModifyIndex": 12
    }
]

请注意,我在容器中的同一台机器上有一些其他服务,尽管不是节点应用程序,但已经成功注册了其地址。我不确定调试它的最佳方法是什么。该应用程序显然可以从docker-compose获取正确的var。尝试调试此程序的任何帮助将不胜感激,谢谢!

0 个答案:

没有答案