阻止 Docker Compose 创建单独的网络

Prevent Docker Compose from creating separate network

我发现 Docker Compose places containers in a separate network when using version 2 他们的 YAML 语法。这使得与现有容器的链接变得困难。

有没有办法避免这种情况,并恢复到 version 1 的行为,而无需实际恢复?

Is there a way to prevent this, and revert to the behavior of version 1, without actually reverting?

在您的服务配置中,指定:

network_mode: bridge

例如:

version: "2"

services:
  web:
    build: web
    network_mode: bridge