Can't connect to any service through localhost (drone 0.7.0)

Hey,

I followed the simplest drone manifest with one service:

pipeline:
  test:
    image: golang
    commands:
      - curl http://localhost:27017

services:
  mongo:
    image: mongo:latest

In the logs I see: curl: (7) Failed to connect to localhost port 27017: Connection refused

  • I see in the logs of ‘drone exec --local’ that the mongo service starts. (also tried with sleep)
  • Not sure if it’s still relevant but I have socat installed as well

Any clue ? further debugging hints?

Thanks.

This is the expected behavior. The docker containers (the container in your pipeline and the mongo container) are on different networks with different IP addresses, and therefore cannot communicate via localhost. Instead you need to use the container hostname.

You can see examples and read more about it here:
http://docs.drone.io/services/
http://docs.drone.io/mongodb-example/

Hey bradry appreciate the work on drone.
But could we put some work into cleaning up the docs.

Spent fair to long believing that they were both on local host due to this http://readme.drone.io/usage/services-guide/. Having no idea it was out of date!
I didn’t even know docs.drone.io was a thing! @bradrydzewski

I do plan to clean up the documentation but have not had the free time or financial resources to fund such an effort. It will get done eventually, but it will take time.