I am using Docker version 17.06.2-ce, build cec0b72 on CentOS 7.2.1511.
I am going through the docker getting started tutorial. I have played around with docker a bit beyond this, but not much.
I have built the friendlyhello
image by copy-pasting from the website. When running with
docker run -d -p 8080:80 friendlyhello
I can curl localhost:8080
and get a response in ~20ms. However, when I run
docker run -p 8080:80 friendlyhello
i.e., without being detached from the container, trying to curl localhost:8080
takes over 50 seconds. This makes no sense to me.
EDIT: 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.
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.
I'm dumb.
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.