大网数据广告活动
服务器运维问答

How do you access a service that is in another stack?

· 52CE 我爱测

I have a docker swarm configuration and in there I deployed two stacks ( main and mon ) I can expose a port in one stack and I can refer to it from another. However, I was trying to find a way of not doing that but instead have i…

问题原文

原帖链接 · Archimedes Trajano · CC BY-SA 3.0

I have a docker swarm configuration and in there I deployed two stacks (main and mon) I can expose a port in one stack and I can refer to it from another. However, I was trying to find a way of not doing that but instead have it access it using the 127.0.0.11 DNS.

In mon I have a service called grafana

Using https://docs.docker.com/docker-cloud/apps/service-links/#discovering-services-or-containers-on-another-stack which indicated that I can use the stack name to refer to it didn't work when I tried to ping grafana.mon it just returned invalid host name.

已采纳解答

原帖链接 · Archimedes Trajano · CC BY-SA 4.0

To do this, all you need is to make it use the same network, then they will be visible. In my case I defined a network called public, that is referred to externally by all my stacks

docker network create -d overlay --attachable public

From there in my docker-compose.yml file I have

networks:
  public:
    external:
      name: public

To access it, just use the service name.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。