[英]How to pull images from private docker registry in drone ci pipeline
操作系統版本:ubuntu 18.04 lts
無人機版本:1.0.0
碼頭工人版本:18.09.4
docker-compose 版本:1.23.2
我自己用 docker 和 docker-compose(一個主,兩個代理)托管了無人機 ci。
示例管道配置:
---
kind: pipeline
name: integration
steps:
- name: tests
image: private-registry.example.com/nodejs/special
commands:
- npm i
- npm run test
when:
event:
- push
- pull_request
...
無人機的文檔是指配置私有注冊表而不提供鏈接或在圖像部分中有關管道步驟的文檔頁面上提供有關如何完成此操作的更多詳細信息,說明:
如果鏡像不存在,Drone 會指示 Docker 拉取它。 如果映像是私有的,您將需要配置注冊表憑據。
我發現了這個問題,其中 op 指的是不再存在的文檔中的此頁面。
問題的作者和接受的答案的作者都在使用無人機 cli 通過registry
命令向無人機添加registry
。 但不幸的是,此命令不再可用。
當前的無人機 cli 使用消息如下所示:
NAME:
drone - command line utility
USAGE:
drone [global options] command [command options] [arguments...]
VERSION:
1.0.7
COMMANDS:
build manage builds
cron manage cron jobs
log manage logs
encrypt encrypt a secret
exec execute a local build
info show information about the current user
repo manage repositories
user manage users
secret manage secrets
server manage servers
queue queue operations
autoscale manage autoscaling
fmt format the yaml file
convert convert legacy format
lint lint the yaml file
sign sign the yaml file
jsonnet generate .drone.yml from jsonnet
script generate .drone.yml from script
plugins plugin helper functions
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
-t value, --token value server auth token [$DRONE_TOKEN]
-s value, --server value server address [$DRONE_SERVER]
--autoscaler value autoscaler address [$DRONE_AUTOSCALER]
--help, -h show help
--version, -v print the version
我發現了一個GitHub的問題,指的是拉請求添加從2014年碼頭工人節這一切似乎已經被轉移到了碼頭工人和碼頭工人:DIND分別插件。
確實有一個專門針對私有 docker 鏡像注冊表的文檔部分。
圖像拉取秘密
為了下載私有映像,您需要提供一個 docker 注冊表配置文件,該文件將身份驗證憑據嵌入到注冊表中。
示例 .docker/config.json 文件:
{ "auths": { "https://index.docker.io/v1/": { "auth": "b2N0b2NhdDpjb3JyZWN0LWhvcnNlLWJhdHRlcnktc3RhcGxl" } } }
文件的內容應存儲為機密,其中命名的機密在 yaml 的 image_pull_secrets 部分中引用。
kind: pipeline name: default type: docker steps: - name: build image: testing/test-image commands: - go build - go test image_pull_secrets: - dockerconfigjson
因此,我們要做的是執行docker login <registry host>
並將從~/.docker/config.json
生成的憑據放在一個秘密中,在名為dockerconfigjson
的示例中。
這是 AWS ECR 的完整工作流程。 假設
aws
CLI 安裝drone
CLI 安裝為您的注冊表獲取令牌: aws ecr get-login-password --region <your region>
將令牌添加到 Drone CI 中的組織: drone orgsecret add <organization> my-pull-secret <secret from step 1>
將以下內容添加到您的.drone.yml
:
image_pull_secrets: - my-pull-secret
對於 Google Cloud,秘密不能是令牌,而是GCloud 文檔中所述的 JSON 文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.