Drone runner can't find server (error no such host)

I am trying to run a gitea server with drone. They are currently both hosted on the same ubuntu machine and the docker containers are set up through a docker-compose.yml file.

When starting up all services I get the following error in the logs of the drone runner service:
time="2020-08-12T19:10:42Z" level=error msg="cannot ping the remote server" error="Post http://drone:80/rpc/v2/ping: dial tcp: lookup drone on 127.0.0.11:53: no such host"

Both http://gitea and http://drone point to localhost (via /etc/hosts). I sadly don’t understand how or why the drone runner can not find the server. Calling “docker container inspect” on all my 4 containers shows they are all connected to the same network (drone_and_gitea_giteanet). Which is also the network I set in the DRONE_RUNNER_NETWORKS environment variable.

This is how my docker-compose.yml file looks:

version: "3.8"

# Create named volumes for gitea server, gitea database and drone server
volumes:
  gitea: 
  gitea-db: 
  drone: 

# Create shared network for gitea and drone
networks:
  giteanet:
    external: false
    
services:
  gitea:
    container_name: gitea
    image: gitea/gitea:1 
    #restart: always
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - ROOT_URL=http://gitea:3000
      - DB_TYPE=postgres
      - DB_HOST=gitea-db:5432
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    networks:
      - giteanet
    ports:
      - "3000:3000"
      - "222:22"
    volumes:
      - gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      - gitea-db

  gitea-db:
    container_name: gitea-db
    image: postgres:9.6 
    #restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - giteanet
    volumes:
      - gitea-db:/var/lib/postgresql/data
    
  drone-server:
    container_name: drone-server
    image: drone/drone:1
    #restart: always
    environment:
      # General server settings
      - DRONE_SERVER_HOST=drone:80
      - DRONE_SERVER_PROTO=http
      - DRONE_RPC_SECRET=topsecret
      
      # Gitea Config
      - DRONE_GITEA_SERVER=http://gitea:3000
      - DRONE_GITEA_CLIENT_ID=<CLIENT ID>
      - DRONE_GITEA_CLIENT_SECRET=<CLIENT SECRET>
      
      # Create Admin User, name should be the same as Gitea Admin user
      - DRONE_USER_CREATE=username:AdminUser,admin:true
      
      # Drone Logs Settings
      - DRONE_LOGS_PRETTY=true
      - DRONE_LOGS_COLOR=true
    networks:
      - giteanet
    ports:
      - "80:80"
    volumes:
      - drone:/data 
    depends_on:
      - gitea   
      
  drone-agent:
    container_name: drone-agent
    image: drone/drone-runner-docker:1 
    #restart: always
    environment:
      - DRONE_RPC_PROTO=http
      - DRONE_RPC_HOST=drone:80
      - DRONE_RPC_SECRET=topsecret
      - DRONE_RUNNER_CAPACITY=1
      - DRONE_RUNNER_NETWORKS=drone_and_gitea_giteanet
    networks:
      - giteanet
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - drone-server

It would help me a lot if somebody could maybe take a look at the issue and help me out! :slight_smile:

based on my understanding of docker-compose, you should use drone-server as the hostname.

By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.

Do you by hostname mean the name of the step inside the .drone.yml file or something inside the docker-compose.yml? I tried setting the hostname for the drone-server container to container_name and that sadly didn’t help. I still get the same error message as above.

drone-server:
    container_name: drone-server
    hostname: drone-server
    image: drone/drone:1    # Latest stable drone image

...

Running docker inspect drone-server shows that the hostname is set correctly too.

"Config": {
            "Hostname": "drone-server",
            "Domainname": "",
            "User": "",
...

Does it maybe have to do with the fact that technically both drone server and gitea are all running on localhost? In this thread you said that that might lead to issues.

Does your config have this right now, or something else?

# General server settings
- DRONE_SERVER_HOST=drone-server
drone-agent:
  container_name: drone-agent
  image: drone/drone-runner-docker:1 
  #restart: always
  environment:
    - DRONE_RPC_PROTO=http
    - DRONE_RPC_HOST=drone-agent

The :80 part shouldn’t matter, it works fine for me without it.