Docker容器间通信非常缓慢(Mac OS X) [英] Docker inter-container communication painfully slow (Mac OS X)

查看:230
本文介绍了Docker容器间通信非常缓慢(Mac OS X)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在容器1的nginx上运行了一个AngularJS应用程序。当它命中 / api时,它将被代理到Docker container2(在Apache上运行的PHP API)。 PHP API访问我的数据库,该数据库在Mac OS X上本地运行。Docker容器是Ubuntu。

I've got an AngularJS application running on nginx in container1. When it hits "/api" it gets proxied over to Docker container2 (a PHP API running on Apache). The PHP API accesses my database that is running locally on Mac OS X. Docker containers are Ubuntu.

容器之间的通信非常缓慢。知道为什么吗?

Communication between containers is very slow. Any idea why?

boot2docker start
docker run -d -h docker --name container2 -v ~/container2dir/:/var/www -p 5000:80 seanbollin/image2
docker run -d -h docker --link name:api -v ~/somefolder/:/var/www/anotherfolder/ -p 5001:80 seanbollin/image1


推荐答案

这可能是由于文件共享部分中的挂载目录。
我有一个50GB的文件夹共享了所有项目。
我共享父文件夹只是为了节省一些时间,但这导致http响应速度变慢。

This could be due to the size of the mounted directory from "File Sharing" section. I had a 50GB around folder shared having all my projects. I shared the parent folder just to save some time, but it caused the slowness in http responses.

仅共享必需的文件夹,并使用.dockerignore您不想挂载的任何文件夹,例如。 venv等。

Share only required folder, and use the .dockerignore for any folder that you don't want to mount, ex. "venv" etc.

这篇关于Docker容器间通信非常缓慢(Mac OS X)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆