[Solved]Unable to access repository but I can clone inside the docker drone

Hi I successfully installed drone and integrated it with my self hosted gitea.

When a commit is pushed, drone give me an error

Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/master:
fatal: unable to access 'http://localhost:3000/josh/go-ci-cd-hw.git/': Failed to connect to localhost port 3000: Connection refused

I used apk to install ssh client to setup a tunnel. I can verify the tunnel work and I can use git to clone the code to the docker.

 git clone http://localhost:3000/josh/go-ci-cd-hw.git/
Cloning into 'go-ci-cd-hw'...
remote: Counting objects: 27, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 27 (delta 9), reused 0 (delta 0)
Unpacking objects: 100% (27/27), done

I don’t know what is wrong? Please help!

localhost:3000 refers to the network inside the clone container, so this error is expected. You need to use the IP address of your Gitea instance or a hostname. Keep in mind that Drone creates a user-defined network for its pipelines. It does not use the default bridge network.

1 Like

Hi; I used this because I need encryption, meanwhile I can’t setup drone access https gitea. But I will start another thread for that. Thank you for your heads up!

In my compose file I use a defined network in bridge mode. I tested: ‘ping’ from drone-server and drone-agent, both see each other. So I believe it’s a buggy behavior on agents. Which ENV variable answers to git-server from an agent? If a drone-server sees git-server already, webhooks, authorize, everything?

  • DRONE_RUNNER_NETWORKS=ci.net (declared in server and agent)

My compose network section:
networks:
ci-net:
name: ci.net
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.202.0/24

Output:
docker exec -it drone-agent sh -c “ping drone-server
PING drone-server (192.168.202.4): 56 data bytes
64 bytes from 192.168.202.4: seq=0 ttl=64 time=0.041 ms
64 bytes from 192.168.202.4: seq=1 ttl=64 time=0.088 ms

docker exec -it drone-server sh -c “ping drone-agent
PING drone-agent (192.168.202.5): 56 data bytes
64 bytes from 192.168.202.5: seq=0 ttl=64 time=0.043 ms
64 bytes from 192.168.202.5: seq=1 ttl=64 time=0.173 ms
64 bytes from 192.168.202.5: seq=2 ttl=64 time=0.079 ms

docker exec -it drone-agent sh -c “ping git-server
PING git-server (192.168.202.3): 56 data bytes
64 bytes from 192.168.202.3: seq=0 ttl=64 time=0.074 ms
64 bytes from 192.168.202.3: seq=1 ttl=64 time=0.139 ms
64 bytes from 192.168.202.3: seq=2 ttl=64 time=0.140 ms

  • Is it a restriction on community edition. I read there is a ENV variable for ENTERPRISE edition that solves this?
  • Why using an external network if containers see each other internally and resolve names?
  • If drone-server contains:
    - DRONE_GITEA=true
    - DRONE_GIT_ALWAYS_AUTH=false
    - DRONE_GITEA_URL=http://git-server:3000
    - DRONE_GITEA_SERVER=http://git-server:3000
    Why does the agent not finds it correctly, even when drone-server sees git-server?

Sigh. The reason it uses localhost:3000 is not because Drone is buggy. It is because this is the clone URL returned from the Gitea API. You need to configure Gitea to provide the correct clone URL.

Many thanks on your response. Indeed, set ROOT_URL in Gitea and everything is well.

ROOT_URL set in /data/gitea/conf/app.ini worked for me.
Mapped as a volume from outside the container. Setting it from docker-compose didn’t work (as ENV variable, seems like gitea ovewrites ENV with app.ini data).

[server]
ROOT_URL=http://git-server:3000

:wink: Great product!