未分离时,Docker容器的http响应速度较慢 [英] Docker container's http response slower when not detached

查看:1604
本文介绍了未分离时,Docker容器的http响应速度较慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Docker版本17.06.2-ce,在CentOS 7.2.1511上构建cec0b72。

I am using Docker version 17.06.2-ce, build cec0b72 on CentOS 7.2.1511.

我正在浏览 docker入门教程。我已经玩过码头有点超过这个,但并不多。

I am going through the docker getting started tutorial. I have played around with docker a bit beyond this, but not much.

我已经通过网站上的复制粘贴构建了 friendlyhello 图像。使用时运行

I have built the friendlyhello image by copy-pasting from the website. When running with

docker run -d -p 8080:80 friendlyhello

我可以 curl localhost:8080 并在~20ms内得到回复。但是,当我运行时

I can curl localhost:8080 and get a response in ~20ms. However, when I run

docker run -p 8080:80 friendlyhello

即,没有从容器中分离,尝试 curl localhost:8080 接管50 。这对我没有意义。

i.e., without being detached from the container, trying to curl localhost:8080 takes over 50 seconds. This makes no sense to me.

编辑:似乎反复查杀容器可能与此有关。无论是那个,还是随机的,给定的容器是否可以快速服务。在使用 -d 标志作为唯一更改停止并启动一堆相同的容器之后,我只看到来自分离容器的快速响应,但是分离的容器也可能很慢响应。我还认为值得一提的是95%以上的慢响应时间是56s或61s。

it seems that killing containers repeatedly may have something to do with this. Either that, or it's random whether a given container can serve quickly or not. After stopping and starting a bunch of identical containers with the -d flag as the only change, I have only seen quick responses from detached containers, but detached containers can also be slow to respond. I also think it's worth mentioning that 95%+ of the slow response times have been either 56s or 61s.

试图研究这个错误让我在容器内运行时,有很多关于卷曲变慢的响应,但这就是我能找到的全部内容。

Trying to research this error gives me plenty of responses about curl being slower when run inside a container, but that is about all I can find.

如果重要的话,我正在使用虚拟机,无法访问主机,我总是root,并且在网络防火墙和代理之后,但我不认为这当只处理localhost时应该很重要。

If it matters, I'm working on a VM, have no access to the host, am always root, and am behind a network firewall and proxy, but I don't think this should matter when only dealing with localhost.

推荐答案

我很笨。

入门教程说,使用此应用程序的http响应可能需要很长时间,因为他们在教程中进一步添加了一个未满足的依赖项。不幸的是,他们在下一页说明了这一点,所以如果你是第2部分和初学者,不清楚为什么会出现这个问题,直到你放弃并继续第3部分。他们声称回复可能需要最多30个秒;我的是两倍,但很明显这是根本原因。

The getting started tutorial says that it can take a long time for http responses with this app because of an unmet dependency that they have you add further in the tutorial. Unfortunately, they say this on the next page, so if you're on part 2 and a beginner, it's not clear why this problem occurs until you give up and go on to part 3. They claim the response may take "up to 30 seconds"; mine is double that, but it's clear that this is the root cause.

这篇关于未分离时,Docker容器的http响应速度较慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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