0

I've seen Gogs + Drone getsockopt: connection refused but I wonder whether something has changed.

My docker-compose.yml

  git:
    image: gogs/gogs
    ports:
      - '8300:3000'
      - '443:443'
      - '8322:22'
    volumes:
      - 'gogs-data:/data'
    depends_on:
      - database
    labels:
      - 'traefik.backend=git'
      - 'traefik.port=3000'
      - 'traefik.frontend.rule=Host:git.drone.localhost'

  drone-server:
    image: drone/drone:0.8

    ports:
      - 8000
      - 9000
    volumes:
      - drone-server-data:/var/lib/drone/
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=http://drone-server:8000
      - DRONE_SECRET=SECRET
      - DRONE_GOGS=true
      - DRONE_GOGS_URL=http://git:3000
      - DRONE_GOGS_SKIP_VERIFY=true

After changing the webhook of my repo in gogs to http://droner-server:8000 I can see drone starting the execution. But it fails cloning the repo:

+ git remote add origin http://git:3000/gituser/repo.git    0s
+ git fetch --no-tags origin +refs/heads/g2:    0s
fatal: unable to access 'http://git:3000/gituser/repo.git/': Could not resolve host: git
miiimooo
  • 91
  • 1
  • 5

1 Answers1

0
  1. Don't forget the version tag at the top
  2. Containers in a docker-compose file cannot access the ports of other containers unless they are the same network. Port 3000 of the git container is where gogs is listening but it is mapped to port 8300 on the host. You could add a bridge network like so:

docker-compose.yaml

    version: '3'
    services:
      git:
        image: gogs/gogs
        ports:
          - '8300:3000'
          - '443:443'
          - '8322:22'
        volumes:
          - 'gogs-data:/data'
        networks:
          - my-net
        depends_on:
          - database
        labels:
          - 'traefik.backend=git'
          - 'traefik.port=3000'
          - 'traefik.frontend.rule=Host:git.drone.localhost'
      drone-server:
        image: drone/drone:0.8
        ports:
          - 8000
          - 9000
        volumes:
          - drone-server-data:/var/lib/drone/
        networks:
          - my-net
        environment:
          - DRONE_OPEN=true
          - DRONE_HOST=http://drone-server:8000
          - DRONE_SECRET=SECRET
          - DRONE_GOGS=true
          - DRONE_GOGS_URL=http://git:3000
          - DRONE_GOGS_SKIP_VERIFY=true
    networks:
      my-net:
        driver: bridge
BMitch
  • 231,797
  • 42
  • 475
  • 450
user1505520
  • 405
  • 1
  • 7
  • 15
  • V3 needs a services section. – BMitch Sep 28 '18 at 21:57
  • ...and will automatically create a network for the containers it launches. (The original problem might occur if it was a V1 `docker-compose.yml` file but the question doesn't include the whole file.) – David Maze Sep 28 '18 at 22:13
  • Apologies. I should have really posted the complete file. It was a version: '2' – miiimooo Oct 05 '18 at 09:27
  • Second problem, I didn't post the drone-agent section. This is actually the service that gives the error message. Updated the original post – miiimooo Oct 05 '18 at 10:43