Tests can't connect to localhost in docker

I’m trying to test a LAMP docker image, following the steps here - https://circleci.com/docs/docker/

I’m trying to CURL localhost:8080 and keep getting an error. My builds can be seen here:

https://circleci.com/gh/mattrayner/docker-lamp

I’m trying to work out why - all of the documentation on Circle seem to say to do it this way

1 Like

I’ve just encountered this same problem, and am very curious as to what the solution is?

Deploying test containers on completely different infrastructure just to confirm they respond seems unnecessarily unwieldy when there is a docker service built into Circle

This post is from a year ago a lot has changed.

Are you using 2.0 or 1.0?

Do you have a link to a failing build that we can look at?

we may be seeing something similar. Our webdriver io run tests started failing with run errors around 20:40ish UTC 17 Oct.

Same tests run normally locally.

I’m continuing to investigate on our end.

using circleci v1

Thanks for the reply Lev, and I actually only realised it was a year old after I posted it, as the date doesn’t indicate year.

I’m experimenting with CircleCI for the first time, using 2.0, and the builds can be viewed here:

https://circleci.com/gh/greenpeace/planet4-docker/32

Tests work locally, but fail each time in Circle.

Currently working on sending all bats output to artifacts for more thorough debugging, but I’m new to bats too…

Updated tests:

https://circleci.com/gh/greenpeace/planet4-docker/tree/feature%2Fcircleci

Have stored all test output from functions as artifacts to get a clearer idea of what’s happening:

https://50-86828145-gh.circle-artifacts.com/0/tmp/artifacts/logs/nginx-pagespeed

As you can see, the container starts successfully but can’t be curled by the test environment.

I thought perhaps the issue was that priveleged ports such as 80 might not be accessible for some reason, and implemented variable port substitution so I could attempt to check connectivity to localhost on arbitrary ports (in this case 8080), but that has the same problem.

What am I missing here?

In addition, I’ve attempted adding the network_mode: "host" flag to docker-compose.yml, to no avail:

https://circleci.com/gh/greenpeace/planet4-docker/56#artifacts/containers/0

So, I’m still confused as to how I can communicate with local docker containers in Circle, and would very much like some direction or assistance here.

1 Like