1.0.0-rc.1 agent doesn't use network

Hello! I’ve been struggling with using 1.0.0-rc.1 in my local dev setup.

The main idea is to run in one network on my own machine GOGS + Drone Server + Drone Agent. Setting them up in the same network makes the build steps unable to access my GOGS setup.

The main idea is to do as follows assuming I have decided on a name for my network ($NETWORK):

docker network create $NETWORK
docker run -d --rm -p 10022:22 -p 3000:3000 --name gogs --network=$NETWORK gogs/gogs
# Set up gogs and some repo at localhost:3000, telling everywhere in the setup that gogs is at host `gogs`
docker run -d --rm --name drone-server -p 8000:80 \
    --env=DRONE_SERVER_HOST=drone-server --env=DRONE_SERVER_PROTO=http \
    --env=DRONE_GOGS_SERVER=http://gogs:3000 --env=DRONE_RPC_SECRET=$SECRET \
    --network=$NETWORK drone/drone:1.0.0-rc.1
docker run -d --rm --name drone-agent \
    --env=DRONE_RPC_SERVER=http://drone-server --env=DRONE_RPC_SECRET=$SECRET \
    -v /var/run/docker.sock:/var/run/docker.sock drone/agent:1.0.0-rc.1
# Set up the webhook at localhost:8000 and make a commit

I tested the main idea of the network with a simple alpine ping test:

docker run --rm --network=$NETWORK -t -i alpine ping -c 1 gogs

Ping goes through with the hostname gogs as expected. How ever when I get to the clone step in my build I get:

Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/some_branch:
fatal: unable to access 'http://gogs:3000/owner/repo.git/': Could not resolve host: gogs

When I disabled the clone step and used a dummy “wait 5 minutes” build step that I could use to debug, I can see that my $NETWORK is not applied to the the container running the build step.

Any ideas on how to make the build step containers use the correct network?

Added a custom clone step with 60s sleep time, during which I manually did docker connect <network> <clonecontainer> after which my clone does work as it should.

1 Like