无法解析主机:git

时间:2018-09-28 14:48:35

标签: docker docker-compose drone drone.io gogs

我见过Gogs + Drone getsockopt: connection refused,但我想知道是否有所改变。

我的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

将我的仓库中的仓库的webhook更改为http://droner-server:8000后,我可以看到无人机开始执行。但这无法克隆存储库:

+ 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

1 个答案:

答案 0 :(得分:0)

  1. 别忘了顶部的版本标签
  2. docker-compose文件中的容器无法访问其他容器的端口,除非它们是同一网络。 git容器的端口3000是gogs侦听的端口,但已映射到主机上的端口8300。您可以像这样添加网桥网络:

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