woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.32k stars 373 forks source link

clone step fails with dockerized agent running on windows with "can't resolve host" #2726

Closed pinna9001 closed 1 year ago

pinna9001 commented 1 year ago

Component

agent

Describe the bug

With the woodpecker server running on a raspberrypi and an agent on my windows pc the clone step fails with "Can't resolve host" When using an agent on a linux pc everything works as intended.

Both agents are using the same exact docker compose file (see below, except for a different secret)

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"1.0.3"}

Additional context

agent docker compose file:

version: "3"

volumes:
  woodpecker-agent-config:

services:
  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:v1.0.3
    container_name: woodpecker-agent
    command: agent
    environment:
      - WOODPECKER_SERVER=raspberrypi:8090
      - WOODPECKER_AGENT_SECRET=<secret>
      - WOODPECKER_FILTER_LABELS=host_os=windows
    restart: unless-stopped
    volumes:
      - woodpecker-agent-config:/etc/woodpecker
      - /var/run/docker.sock:/var/run/docker.sock

clone step log:

+ git init -b main
Initialized empty Git repository in /woodpecker/src/raspberrypi/pinna9001/repo/.git/
+ git config --global safe.directory /woodpecker/src/raspberrypi/pinna9001/repo
+ git remote add origin http://raspberrypi:3080/pinna9001/repo.git
+ git fetch --no-tags --depth=1 --filter=tree:0 origin +main:
fatal: unable to access 'http://raspberrypi:3080/pinna9001/repo.git/': Could not resolve host: raspberrypi
exit status 128

Validations

pinna9001 commented 1 year ago

I can ping external hostname like google.com but not my internal hostnames. Pinging the ip address also works. The problems are only happening in the containers, that are started of the agent container.

pinna9001 commented 1 year ago

Problem fixed by adding a dns entry to the daemon.json of docker. I don't really understand why the woodpecker-agent can resolve the hostname and the clone step can't. I also don't understand why the agent doesn't forward the information to the (clone) steps.