Docker: 在默认值中找不到可用的、非重叠的 IPv4 地址池以分配给网络

Docker: Could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

当我尝试使用 docker-compose 部署我的应用程序时,我收到了以下错误:

Creating network "<myapplicationnamehere_mycustomnetwork>" with the 
default driver
could not find an available, non-overlapping IPv4 address pool among 
the defaults to assign to the network

现在我在这里和那里进行了一些研究,人们建议将未使用的旧 docker 网络与 docker network prune 连接起来。但是因为我 运行 正在使用 34 docker 个容器(我认为大约有 30 个网络),在错误再次发生之前它只 p运行es 一个或两个旧网络。

我的问题是:如何确保我可以 运行 许多服务而不 运行 陷入 docker 网络分配问题。 (也许以某种方式创建更小的子网?)

docker-compose 文件的顶级网络部分如下所示:

#
# Networks section
# Networks:
# - public, represents the network between nginx and the public nginx-proxy (which should be already running)
# - uwsgi, represents the network between nginx and uwsgi
# - postgres, represents the network between uwsgi and postgres
#
networks:
  uwsgi:
  postgres:
  public:
    external:
      name: nginx-proxy

自 Docker 18.06 以来,您可以使用默认地址池 属性 指定自定义地址范围。另见 the associated Pull Request