Gogs + Drone getsockopt:连接被拒绝 [英] Gogs + Drone getsockopt: connection refused

查看:590
本文介绍了Gogs + Drone getsockopt:连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gogs/webhooks界面中,当我单击测试交付按钮时,出现此错误;

In the Gogs/webhooks interface when i click the test delivery button i got this error;

投放张贴 HTTP://本地主机:8000/钩=的access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoidG9tL2Ryb255IiwidHlwZSI6Imhvb2sifQ .UZdOVW2IdiDcLQzKcnlmlAxkuA8GTZBH634G0K7rggI :拨打tcp [:: 1]:8000:getsockopt:连接被拒绝

Delivery: Post http://localhost:8000/hook?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoidG9tL2Ryb255IiwidHlwZSI6Imhvb2sifQ.UZdOVW2IdiDcLQzKcnlmlAxkuA8GTZBH634G0K7rggI: dial tcp [::1]:8000: getsockopt: connection refused

这是我的docker-compose.yml文件

This is my docker-compose.yml file

version: '2'
services:
  gogs:
    image: gogs/gogs
    ports:
      - 3000:3000
      - 22:22
    links:
      - mysql

  mysql:
    image: mysql
    expose:
      - 3306
    environment:
      - MYSQL_ROOT_PASSWORD=1234
      - MYSQL_DATABASE=gogs

  drone:
    image: drone/drone
    links:
     - gogs
    ports:
      - 8000:8000
    volumes:
      - ./drone:/var/lib/drone 
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - REMOTE_DRIVER=gogs
      - REMOTE_CONFIG=http://gogs:3000?open=true
      # - PUBLIC_MODE=true

推荐答案

根本原因是Drone假定其外部地址为localhost:8000,因为这是从您的浏览器访问它的方式.因此,无人机将所有Gogs Webhook配置为使用localhost:8000/hook作为回调URL.

The root cause is that Drone assumes its external address is localhost:8000 because that is how it is being accessed from your browser. Drone therefore configures all Gogs webhooks to use localhost:8000/hook as the callback URL.

这里的问题是Gogs和Drone在不同网络上的不同容器中运行.这意味着当Gogs尝试将钩子发送给无人机时,它将钩子发送到localhost:8000并失败,因为Drone在单独的网桥上.

The problem here is that Gogs and Drone are running in separate containers on separate networks. This means when Gogs tries to send the hook to drone it sends it to localhost:8000 and fails because Drone is on a separate bridge.

推荐的修复程序

建议的解决方法是将DNS或IP地址与Drone and Gogs一起使用.如果您正在运行这两个系统的生产安装,则不太可能使用localhost,因此这似乎是合理的解决方案.

The recommended fix is to use DNS or an IP address with Drone and Gogs. If you are running a production installation of either system it is unlikely you will be using localhost, so this seems like reasonable soluation.

对于本地测试,您还可以使用Docker分配的本地IP地址.您可以使用Docker inspect找到您的Drone和Gogs IP地址:

For local testing you can also use the local IP address assigned by Docker. You can find your Drone and Gogs IP addresses using Docker inspect:

"Networks": {
  "default": {
    "IPAddress": "172.18.0.3"
  }
}

为什么不自定义主机名?

使用自定义主机名(例如 http://gogs )是有问题的,因为无人机会使用默认设置为每个版本创建临时Docker容器Docker网络设置.这意味着您的构建环境将使用其自己的隔离网络,并且将无法解析 http://gogs

Using custom hostnames, such as http://gogs, is problematic because drone creates ephemeral Docker containers for every build using the default Docker network settings. This means your build environment will use its own isolated network and will not be able to resolve http://gogs

因此,即使我们将Drone和Gogs配置为使用自定义主机名进行通信,构建环境也将无法解析Gogs主机名来克隆您的存储库.

So even if we configured Drone and Gogs to communicate using custom hostnames, the build environment would be unable to resolve the Gogs hostname to clone your repository.

这篇关于Gogs + Drone getsockopt:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆