简体   繁体   English

与不同桥接网络中的多个 docker-compose.yml 通信

[英]Communication with mutiple docker-compose.yml which are in different bridge network

Suppose i have multiple docker-compose.yml with some static ip's and i want to connect them with each other without exposing the ports.假设我有多个 docker-compose.yml 和一些 static ip,我想在不暴露端口的情况下将它们相互连接。 Which network type would be suitable to achieve that overlay or bridg?哪种网络类型适合实现覆盖或桥接?

Technically, you don't connect docker-compose.yml files, you connect services defined in the compose file(s).从技术上讲,您不连接 docker-compose.yml 文件,而是连接撰写文件中定义的服务。

If you'll run the compose files on the same docker host machine, you can create a network and reference that network in your compose files as external network like so :如果您将在同一台 docker 主机上运行撰写文件,您可以创建一个网络并在您的撰写文件中将该网络引用为外部网络,如下所示

networks:
  default:
    external:
      name: my-pre-existing-network

If you run your compose files on different docker host machines and don't want to expose ports to the outside world, you can configure your firewall to allow connections only from specific IPs to these ports, configure your application to respond only to specific IPs, bind the Docker ports to specific IPs or create SSH tunnels between the machines (although the SSH port should be exposed)如果您在不同的 docker 主机上运行您的撰写文件并且不想将端口暴露给外界,您可以将防火墙配置为仅允许从特定 IP 到这些端口的连接,将您的应用程序配置为仅响应特定 IP,将 Docker 端口绑定到特定 IP或在机器之间创建 SSH 隧道(尽管应该暴露 SSH 端口)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM