Accessing services to test containers before deploy

docker

#1

https://circleci.com/docs/2.0/building-docker-images/#accessing-services

Following the section above, it works locally on my machine but getting this when I try it on CircleCI. Are the docs up to date?

# Next ping the healthcheck URL.
docker exec test-container curl --retry 10 http://localhost:3000
f11393aee3f8630b4cb31bf1b8773d5dea05cdf7c130181ac8c9e0215bf83d18
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed connect to localhost:3000; Connection refused
Exited with code 7

See this build if you need more info: https://circleci.com/gh/hugoai/hg-api/372

Any suggestions?

Thanks,
Alex


#2

I recommend SSHing to debug and find out why. Running ss -plntu or netstat -plntu in that test-container will show you what’s listening.


#3

Hi Alex, you’re missing a flag. The command from the docs is:

docker exec my-app curl --retry 10 --retry-connrefused http://localhost:8080

Note from the curl man page

–retry-connrefused

In addition to the other conditions, consider ECONNREFUSED as a transient error too for --retry. This option is used together with --retry.

You can tell there were no retries on your build because the failed step took 0 seconds to execute, but curl uses exponential backoff so each retry should wait 1, 2, 4, 8 seconds and so on.


#4

Cool looks like that’s the issue, just need to upgrade our Centos 7 container to include the newer version of cURL now :confused: (It’s failing now because it has v7.29 but it needs v7.52).

Thanks for the help :slight_smile:


#5