Drone runner 一直 在 pending

来源:3-18 项目持续集成之流水线配置

慕桂英5445302

2025-07-10

操作系统 macOS

麻烦 老师 帮忙 给指导一下

docker-compose.yaml

volumes:
  dronedata:
services:
  # drone服务端 注意ip需要修改自己注意对应的IP
  drone-server:
    image: drone/drone:2
    environment:
      DRONE_AGENTS_ENABLED: "true"
      DRONE_GOGS_SERVER: "http://gogs:3000"
      #命令 openssl rand -hex 16 生成 注意server要和runner保持一致
      DRONE_RPC_SECRET: "aafa571e9e6af4a01dd0c61892a5216e"
      DRONE_SERVER_HOST: "host.docker.internal:9080"
      DRONE_SERVER_PROTO: "http"
      #设置imooc为管理员权限,这样才能做更多的设置
      DRONE_USER_CREATE: "username:imooc,machine:false,admin:true,token:ad47d5f1a2bbd9b1b820a7ee30785ce630777603"
    restart: always
    container_name: drone-server
    ports:
      - 9080:80
      - 9443:443
    volumes:
      - dronedata:/data
  # drone 客户端
  drone-runner:
    image: drone/drone-runner-docker:1
    environment:
      DRONE_RPC_PROTO: "http"
      DRONE_RPC_HOST: "drone-server:80"
      DRONE_RPC_SECRET: "aafa571e9e6af4a01dd0c61892a5216e"
      DRONE_RUNNER_CAPACITY: "4"
      DRONE_RUNNER_NAME: "my-first-runner"
      DRONE_DEBUG: true

    ports:
      - 3001:3000
    restart: always
    container_name: drone-runner
    depends_on:
      - drone-server
    volumes:
      - /Users/momo/.docker:/etc/docker
      - /var/run/docker.sock:/var/run/docker.sock

.drone.yml

kind: pipeline
type: docker
name: kubeimooc-web-publish

environment:
  GOOS: linux
  GOARCH: amd64

steps:
- name: build
  image: plugins/docker:20.14.2
  timeout: 600
  volumes:
    - name: hosts
      path: /etc/hosts
    - name: docker-ca
      path: /Users/momo/.docker
    - name: dockersock
      path: /var/run/docker.sock
  settings:
    username: admin
    password:
      from_secret: harbor_password
    repo: harbor.cole.com/kubeimooc/web
    registry: harbor.cole.com
    tags:
      - v1.1
- name: ssh commands
  image: appleboy/drone-ssh:1.6.13
  settings:
    host: 172.17.50.65
    username: momo
    password:
      from_secret: ssh_password
    port: 22
    script:
      # 拉取镜像并重启
      - if [ $(docker ps -a | grep web | wc -l ) -ge 1 ]; then docker stop web && docker rm web; fi
      - docker pull harbor.cole.com/kubeimooc/web:v1.1
      - export BACKEND_HOST=http://172.17.50.65:8080/
      - docker run --name web -d -p8081:80 -e BACKEND_HOST=$BACKEND_HOST harbor.cole.com/kubeimooc/web:v1.1
volumes:
- name: hosts
  host:
    path: /etc/hosts
- name: docker-ca
  host:
    path: /Users/momo/.docker
- name: dockersock
  host:
    path: /Users/momo/.docker/run/docker.sock

runner log

time="2025-07-10T09:39:45Z" level=debug msg="successfully pinged the docker daemon"

time="2025-07-10T09:39:45Z" level=info msg="starting the server" addr=":3000"

time="2025-07-10T09:39:45Z" level=error msg="cannot ping the remote server" error="Post \"http://drone-server:80/rpc/v2/ping\": dial tcp 172.21.0.2:80: connect: connection refused"

time="2025-07-10T09:39:46Z" level=info msg="successfully pinged the remote server"

time="2025-07-10T09:39:46Z" level=info msg="polling the remote server" arch=arm64 capacity=4 endpoint="http://drone-server:80" kind=pipeline os=linux type=docker

time="2025-07-10T09:39:46Z" level=debug msg="poller: request stage from remote server" thread=4

time="2025-07-10T09:39:46Z" level=debug msg="poller: request stage from remote server" thread=2

time="2025-07-10T09:39:46Z" level=debug msg="poller: request stage from remote server" thread=1

time="2025-07-10T09:39:46Z" level=debug msg="poller: request stage from remote server" thread=3

server log


{"admin":true,"level":"info","login":"imooc","machine":false,"msg":"bootstrap: account created","time":"2025-07-10T09:39:45Z","token":"ad47d5f1a2bbd9b1b820a7ee30785ce630777603"}

{"interval":"30m0s","level":"info","msg":"starting the cron scheduler","time":"2025-07-10T09:39:45Z"}

{"interval":"24h0m0s","level":"info","msg":"starting the zombie build reaper","time":"2025-07-10T09:39:45Z"}

{"acme":false,"host":"host.docker.internal:9080","level":"info","msg":"starting the http server","port":":80","proto":"http","time":"2025-07-10T09:39:45Z","url":"http://host.docker.internal:9080"}

尝试了最小的配置 还是一样的有问题

kind: pipeline
type: docker
steps:
  - name: test
    image: alpine
    commands: [echo "Hello"]
写回答

2回答

慕桂英5445302

提问者

2025-07-15

这里核心点是 .drone.yml 中需要指定和 runner 一样的系统架构,这里需要查询 runner 的架构信息 并且在 .drone.yml 中明确指定,不然就会导致 runner 一直在 pending 状态 

step1 查询当前 runner 的架构信息

docker inspect  drone-runner | grep ARCH

step2 在 yml 中新增对应的信息

kind: pipeline
type: docker
name: cole

# 核心关键点
platform:
  os: linux
  arch: arm64

steps:
  - name: test
    image: alpine:3.18
    commands:
      - echo "Hello World from ARM64!"

这样就能保证 流水线不在 pending 状态


但是在 mac 上操作的话后续可能还会有很多问题需要解决

  1. server、runner 和宿主机通信问题

  2. harbor 协议问题

  3. runner 拉代码问题

  4. npm 安装命令证书问题

  5. 宿主机没有开启 ssh 服务问题

  6. ssh 登录宿主机找不到 docker 命令的问题

这次排查问题最大的阻碍就是 runner 镜像是一个极简镜像,导致很多命令不能执行。如果可以的话 可以自己基于基础镜像构建一个 runner


也可以在官网寻找其他的 runner 执行(runner 的本质 其实 是类似消息中间件的消费者)

https://docs.drone.io/runner/overview/

2
0

暮闲

2025-07-10

感觉问题比较奇怪 你先在qq群里私我一下 我给你远程看下 然后再把答案贴在这里

0
1
慕桂英5445302
感谢老师的帮助,对应的解决方案已经同步
2025-07-15
共1条回复

Kubernetes系统精讲 Go语言实战K8S集群可视化

核心知识+高阶应用+原理剖析+二次开发 全方位打通K8S生产实践

412 学习 · 272 问题

查看课程