在 drone.io 上使用 dind

Using dind on drone.io

我正在尝试从 gitlab ci 迁移到 drone.io。但是我不能让 DIND 像在 gitlab 上那样工作。以上是我在gitlab上的做法。

variables:
  NODE_ENV: 'test'
  DOCKER_DRIVER: overlay

image: gitlab/dind

services:
  - docker:dind

cache:
  untracked: true

stages:
  - test

test:
  stage: test
  before_script:
    - docker info
    - docker-compose --version
    - docker-compose pull
    - docker-compose build
  after_script:
    - docker-compose down
  script:
    - docker-compose run --rm api yarn install

如何创建等效的无人机文件?

您可以使用服务部分启动 docker 守护程序。

pipeline:
  ping:
    image: docker
    environment:
      - DOCKER_HOST=unix:///drone/docker.sock
    commands:
      - sleep 10 # give docker enough time to initialize
      - docker ps -a

services:
  docker:
    image: docker:dind
    privileged: true
    command: [ '-H', 'unix:///drone/docker.sock' ]

请注意,我们更改了 docker 套接字的默认位置并写入管道中所有容器共享的无人机卷:

command: [ '-H', 'unix:///drone/docker.sock' ]

另请注意,我们需要 运行 特权模式下的 dind 容器。特权标志只能由受信任的存储库使用。因此,您需要用户管理员在无人机用户界面中为您的存储库将可信标志设置为 true。

privileged: true