Drone

Cannot connect to other container, what am I missing?

Hi there,

I have a pipeline where I want to test an api. I build a docker image using the docker plugin, then I start the container from that plugin detached.
In the next pipeline step I would like to run a program which connects to the service. This does not work and gives me the following error:

EndpointWriter failed to connect address="customerservice:9010" error="rpc error: code = Unavailable 
desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = 
\"transport: Error while dialing dial tcp: lookup customerservice on 127.0.0.11:53: no such host\"" 

I am running drone with the docker runner. My docker-compose-file looks like:

version: "3"
services:
  nginx:
    build:
      context: .
      dockerfile: nginx.dockerfile
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /home/obraun/certs:/etc/nginx/certs:ro
    ports:
      - 80:80
      - 443:443
    depends_on:
      - drone
    networks:
      - frontend
      - backend
    restart: always

  drone:
    image: drone/drone:1
    volumes:
      - /home/dronedata:/data
    environment:
      - VIRTUAL_HOST=...
      - VIRTUAL_PORT=...
      - DRONE_AGENTS_ENABLED=true
      - DRONE_GITHUB_CLIENT_ID=...
      - DRONE_GITHUB_CLIENT_SECRET=...
      - DRONE_RPC_SECRET=...
      - DRONE_SERVER_HOST=...
      - DRONE_SERVER_PROTO=https
      - DRONE_USER_CREATE=...
    networks:
      - backend
    restart: always

  runner:
    image: drone/drone-runner-docker:1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_RPC_PROTO=http
      - DRONE_RPC_HOST=drone
      - DRONE_RPC_SECRET=...
      - DRONE_RUNNER_CAPACITY=15
      - DRONE_RUNNER_NAME=runner
    depends_on:
      - drone
    networks:
      - backend
    restart: always

networks:
  frontend:
  backend:

My drone.yml looks like this:

kind: pipeline
type: docker
name: default

steps:
    - name: docker (customerservice)
      image: plugins/docker
      settings:
          dockerfile: customer/service/Dockerfile
          username: obcode
          password:
              from_secret: gh_token
          registry: docker.pkg.github.com
          repo: docker.pkg.github.com/vesose/solutionb1/customerservice
      when:
          branch:
              - master
              - develop

    - name: customerservice
      image: docker.pkg.github.com/vesose/solutionb1/customerservice
      detach: true

    - name: test (customerservice)
      image: obraun/golang-protoactor-ci
      commands:
          - sleep 5
          - go run apitest/customer.go -use-external-service -service=customerservice:9010

image_pull_secrets:
    - dockerconfig

Any hints or help would be very great.

Thanks
Olli

I’m in a very similar situation, does detached steps share network?

I’m in a very similar situation, does detached steps share network?

Yes, services are just syntactic sugar for detached pipeline steps, so they work the same way. Here is a working example of a pipeline step communicating with a detached step:

kind: pipeline
name: default

steps:
- name: redis
  image: redis
  detach: true

- name: test
  image: redis
  commands:
  - sleep 5
  - redis-cli -h redis ping
  - redis-cli -h redis set FOO bar
  - redis-cli -h redis get FOO

We tested the above configuration to ensure if passes. You can see the results here:
https://cloud.drone.io/drone/hello-world/124

It works now for me too. I still don’t know why it didn’t work with the proto.actor project.

Now, I have a project up and running with etcd, NATS, redis and 4 microservices, developed with micro.mu.

Thanks for Drone. I am using CI (Jenkins, Travis, GitHub Actions, …) since a lot of years for checking the exercises of my students. Drone CI is simply the coolest of all!

It’s working for me as well, it’s was not obvious for me that the step name would become the hostname for the container.