Drone 插件市场

Drone 插件文档

原文地址 - Docker 插件的手册

Docker 插件可以用于构建镜像及发布镜像到 Docker registry。下面的 pipeline 配置,就使用了 Docker 插件来构建和发布镜像:

pipeline:
docker:
image: plugins/docker
username: kevinbacon
password: pa55word
repo: foo/bar
tags: latest

使用多个 tag 的示例配置:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
- tags: latest
+ tags:
+ - latest
+ - 1.0.1
+ - 1.0

使用 .tag 文件(用逗号分隔的 tag 列表)的示例配置:

pipeline:
build:
image: golang:1.10.0-alpine
commands:
- [...]
+ - echo -n "5.2.6,5.2.4" > .tags
docker:
image: plugins/docker
repo: foo/bar
- tags: latest

使用 build_args 参数的示例配置:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
+ build_args:
+ - HTTP_PROXY=http://yourproxy.com

使用备用 Dockerfile 的示例配置:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
- dockerfile: Dockerfile
+ dockerfile: path/to/Dockerfile

使用自定义 registry 的示例配置:

pipeline:
docker:
image: plugins/docker
- repo: foo/bar
+ repo: index.company.com/foo/bar
+ registry: index.company.com

使用行内凭据(inline credentials)的示例配置:

pipeline:
docker:
image: plugins/docker
+ username: kevinbacon
+ password: pa55word
repo: foo/bar

使用 secrets 中的凭据(通过 Drone 的 web 页面添加)的示例配置:

pipeline:
docker:
image: plugins/docker
- username: kevinbacon
- password: pa55word
repo: foo/bar
+ secrets: [ docker_username, docker_password ]

自动打标签 Autotag

Docker 插件可以被配置成自动为你的镜像创建 tag。当开启这个特性且事件类型是 tag 时,插件会自动使用标准的 major、minor、release 惯例为镜像创建 tag。例如:

  • 1.0.0 生成 docker tag 1, 1.0, 1.0.0
  • 1.0.0-rc.1 生成 docker tag 1.0.0-rc.1

当事件类型是 push 并且目标分支是你的默认分支(例如 master)时,插件会自动为镜像添加 latest 这个 tag。所有其他的事件类型和分支都会被忽略。

示例配置:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
+ auto_tag: true
secrets: [ docker_username, docker_password ]

使用了 tag 后缀的示例配置:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
+ auto_tag: true
+ auto_tag_suffix: linux-amd64
secrets: [ docker_username, docker_password ]

请注意,自动标记 auto_tag 是故意简单和无法定制的,目前不接受 pull 请求以进一步定制逻辑。

多阶段构建(Multi-stage builds)

Docker 插件允许在 官方文档 中描述的 Dockerfile 中定义的特定阶段停止构建。如果未定义 target 属性,则 Docker 插件不会在任何阶段停止,此时只会构建完整的 Docker 镜像。

The Docker plugin allow to stop build at a specific stage defined in Dockerfile as described in the official docs. If the target attribute is not defined, the Docker plugin will not stop at any stage and build the full docker image.

Dockerfile 示例:

FROM golang as builder
WORKSPACE /go/src/github.com/foo/bar
RUN CGO_ENABLED=0 GOOS=linux go build -o demo main.go FROM scratch as production
COPY --from=builder /go/src/github.com/foo/bar/demo .
CMD ["./demo"] FROM alpine as debug
COPY --from=builder /go/src/github.com/foo/bar/demo .
CMD ["./demo"]

允许构建生产环境 Docker 镜像的示例配置:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
+ target: production
secrets: [ docker_username, docker_password ]

下面这个会构建 debug 环境 Docker 镜像:

pipeline:
docker:
image: plugins/docker
repo: foo/bar
+ target: debug
secrets: [ docker_username, docker_password ]

Secret 手册

  • docker_username:使用此用户名进行身份验证
  • docker_password:使用此密码进行身份验证

Parameter 手册

  • registry:向这个 registry 进行验证
  • username:使用此用户名进行身份验证
  • password:使用此密码进行身份验证
  • repo:用于存储镜像的仓库名
  • tags:用于镜像的仓库的 tag
  • dockerfile:要使用的 dockerfile,默认是 Dockerfile
  • auth:registry 的身份验证 token
  • context:要使用的上下文路径,默认为 git 仓库的根目录
  • target:要使用的构建目标,必须在 dockerfile 中定义
  • force_tag=false:替换现有的匹配到的镜像的 tag
  • insecure=false:启用对此 registry 的不安全通信
  • mirror:使用 registry 镜像,而不是直接从 Docker 默认的 Hub 中获取镜像
  • bip=false:用于传递 bridge IP
  • custom_dns:为容器设置自定义 DNS 服务器
  • storage_driver:支持 aufs,overlay 或 vfs 驱动程序
  • build_args:自定义参数传递给 docker build
  • auto_tag=false:根据 git 分支和 git 标签自动生成标签名称
  • auto_tag_suffix:用这个后缀生成标签名称
  • debug, launch_debug:以详细调试模式启动 docker 守护进程

Drone 的插件 - Docker 插件的更多相关文章

  1. Intellij IDEA使用Docker插件部署应用

    1.安装Docker插件 配置Docker Api,在API URL中填入api的地址,记得Docker后台程序启动是要配置 -H tcp://0.0.0.0:2375 开放远程地址端口,注意这里的i ...

  2. maven添加docker插件无法引入,运行时报错 No plugin found for prefix 'docker'

    maven 安装不上docker插件,运行 提示:docker:bulid时No plugin found for prefix 'docker' 原因是maven不能识别 docker-maven- ...

  3. mac下idea中安装docker插件

    idea中安装docker插件: 点击Intellij IDEA->Preferences...->Plugins->Browse repositories...如下: 点击Inst ...

  4. idea使用docker插件

    idea使用docker插件 接着上一篇docker开启远程访问后,我们就可以通过idea使用docker插件把项目部署到docker了. 首先我们先在idea安装docker插件: 在setting ...

  5. idea安装docker插件

    Preferences->Plugins 根据上图安装docker插件,安装完成后可使用idea来管理docker项目了.docker运行项目请参加"Docker开发环境搭建" ...

  6. Docker开启远程连接,本地IDEA使用docker插件连接(不认证的版本和认证的版本都有)

    前言 在学校学习的时候,要部署一个Java程序,一般是打成war包,放到服务器上的tomcat的webapp里面去: 后来SpringBoot出现内置了tomcat,就直接打成jar包,丢到服务器任何 ...

  7. IDEA集成Docker插件后出现日志乱码的解决办法

    修改IDEA的vmoptions文件 找到IDEA安装目录的bin目录,在idea.exe.vmoptions和idea64.exe.vmoptions文件中追加以下内容: -Dfile.encodi ...

  8. Docker实战 | 第二篇:IDEA集成Docker插件实现一键自动打包部署微服务项目,一劳永逸的技术手段值得一试

    一. 前言 大家在自己玩微服务项目的时候,动辄十几个服务,每次修改逐一部署繁琐不说也会浪费越来越多时间,所以本篇整理通过一次性配置实现一键部署微服务,实现真正所谓的一劳永逸. 二. 配置服务器 1. ...

  9. idea中使用docker插件部署项目

    安装docker 如果你之前安装过 docker,请先删掉 sudo yum remove docker docker-common docker-selinux docker-engine 安装一些 ...

随机推荐

  1. mysql查询字段类型为json时的两种查询方式。

    表结构如下: id        varchar(32) info     json 数据: id = info = {"age": "18","di ...

  2. FZUOJ-2275 Game

     Problem 2275 Game Accept: 159    Submit: 539 Time Limit: 1000 mSec    Memory Limit : 262144 KB  Pro ...

  3. 关于 Python 程序的运行方面,有什么手段能提升性能?

    1.使用多进程,充分利用机器的多核性能2.对于性能影响较大的部分代码,可以使用 C 或 C++编写3.对于 IO 阻塞造成的性能影响,可以使用 IO 多路复用来解决4.尽量使用 Python 的内建函 ...

  4. P2835 刻录光盘 (tarjan缩点)

    [题目描述] 现在假设总共有N个营员(2<=N<=200),每个营员的编号为1~N.LHC给每个人发了一张调查表,让每个营员填上自己愿意让哪些人到他那儿拷贝资料.当然,如果A愿意把资料拷贝 ...

  5. Nodejs中request出现ESOCKETTIMEDOUT解决方案

    做需求的时候,使用Nodejs的request批量请求某一个接口,由于接口超时,出现 ESOCKETTIMEDOUT,程序中断 为了让程序遇到 ESOCKETTIMEDOUT 之后能够继续执行下去,需 ...

  6. 从excel表中生成批量SQL

    excel表格中有许多数据,需要将数据导入数据库中,又不能一个一个手工录入,可以生成SQL,来批量操作.   ="insert into Log_loginUser (LogID, Logi ...

  7. mysql导出函数或者存储过程 设置显示方式

    mysql导出函数或者存储过程 mysqldump -hhostname -uusername -ppassword -ntd -R databasename > /app/backupflie ...

  8. ubuntu16.04安装mysql数据库

    安装 sudo apt-get install mysql-server(安装过程中按提示设置root密码) sudo apt-get install mysql-client sudo apt-ge ...

  9. [SDOI2015]寻宝游戏(LCA,set)

    [SDOI2015]寻宝游戏 题目描述 小B最近正在玩一个寻宝游戏,这个游戏的地图中有N个村庄和N-1条道路,并且任何两个村庄之间有且仅有一条路径可达.游戏开始时,玩家可以任意选择一个村庄,瞬间转移到 ...

  10. 转义字符\e

    Windows 平台下,conio.h 中有许多操作控制台颜色.格式的函数.但是再 Linux 平台下却没有类似的函数.经过在网上的一番搜索,找到了解决此问题的方法——转义字符\e.注意,\e这种写法 ...