简体   繁体   English

docker-compose 重新启动连接池已满

[英]docker-compose restart connection pool full

My team and I are converting some of our infrastructure to docker using docker-compose.我和我的团队正在使用 docker-compose 将我们的一些基础设施转换为 docker。 Everything appears to be working great the only issue I have is doing a restart it gives me a connection pool is full error.一切似乎都运行良好,我遇到的唯一问题是重新启动它给我一个连接池已满错误。 I am trying to figure out what is causing this.我想弄清楚是什么导致了这种情况。 If I remove 2 containers or (1 complete setup) it works fine.如果我移除 2 个容器或(1 个完整设置),它可以正常工作。

A little background on what I am trying to do.关于我正在尝试做的事情的一些背景知识。 This is a Ruby on Rails application that is being ran with multiple different configurations for different teams within an organization.这是一个 Ruby on Rails 应用程序,它为组织内的不同团队以多种不同的配置运行。 In total the server is running 14 different containers.服务器总共运行 14 个不同的容器。 The host server OS is CentOS, and the compose command is being ran from a MacBook Pro on the same network.主机服务器操作系统是 CentOS,撰写命​​令是从同一网络上的 MacBook Pro 运行的。 I have also tried this with a boot2docker VM with the same result.我也用 boot2docker VM 尝试过这个,结果相同。

Here is the verbose output from the command (using the boot2docker vm) https://gist.github.com/rebelweb/5e6dfe34ec3e8dbb8f02c0755991ef11这是命令的详细输出(使用 boot2docker vm) https://gist.github.com/rebelweb/5e6dfe34ec3e8dbb8f02c0755991ef11

Any help or pointers is appreciated.任何帮助或指示表示赞赏。

I have been struggling with this error message as well with my development environment that uses more than ten containers executed through docker-compose .我一直在努力解决此错误消息以及使用通过docker-compose执行的十多个容器的开发环境。

WARNING: Connection pool is full, discarding connection: localhost

I think I've discovered the root cause of this issue.我想我已经发现了这个问题的根本原因。 The python library requests maintains a pool of HTTP connections that the docker library uses to talk to the docker API and, presumably, the containers themselves. python 库requests维护一个 HTTP 连接池, docker库使用该池与 docker API 进行通信,并且可能与容器本身进行通信。 It's my hypothesis that only those of us that use docker-compose with more than 10 containers will ever see this.我的假设是,只有我们这些使用 docker-compose 和 10 个以上容器的人才能看到这一点。 The problem is twofold.问题是双重的。

  • requests defaults its connection pool size to 10, and requests默认其连接池大小为 10,并且
  • there doesn't appear to be any way to inject a bigger pool size from the docker-compose or docker libraries似乎没有任何方法可以从docker-composedocker库中注入更大的池大小

I hacked together a solution.我一起破解了一个解决方案。 My libraries for requests were located in ~/.local/lib/python2.7/site-packages .我的requests库位于~/.local/lib/python2.7/site-packages I found requests/adapters.py and changed DEFAULT_POOLSIZE from 10 to 1000.我找到了requests/adapters.py并将DEFAULT_POOLSIZE从 10 更改为 1000。

This is not a production solution, is pretty obscure, and will not survive a package upgrade.这不是生产解决方案,非常晦涩难懂,并且无法在软件包升级中幸免于难。

You can try reset network pool before deploy您可以在部署前尝试重置网络池

$ docker network prune

Docks here: https://docs.docker.com/engine/reference/commandline/network_prune/停靠在这里: https : //docs.docker.com/engine/reference/commandline/network_prune/

I got the same issue with my Django Application.我的 Django 应用程序遇到了同样的问题。 Running about 70 containers in docker-compose.在 docker-compose 中运行大约 70 个容器。 This post heled me since it seems that prune is needed after setting COMPOSE_PARALLEL_LIMIT这篇文章让我受益匪浅,因为在设置 COMPOSE_PARALLEL_LIMIT 后似乎需要修剪

I did:我做了:

docker-compose down
export COMPOSE_PARALLEL_LIMIT=1000
docker network prune
docker-compose up -d

For future readers.对于未来的读者。 A small addition to the answer by @andriy-baran You need to stop all containers, delete them and them run network prune (because the prune command removes unused networks only) @andriy-baran 回答的一个小补充 您需要停止所有容器,删除它们,然后运行 ​​network prune (因为 prune 命令仅删除未使用的网络)

So something like this:所以像这样:

docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker network prune

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

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