2016-12-14 17:29:50 +00:00
---
date: 2016-01-01T00:00:00+00:00
title: Docker
author: drone-plugins
tags: [ publish, docker ]
repo: drone-plugins/drone-docker
image: plugins/drone
---
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
The Docker plugin can be used to build and publish images to the Docker registry. The following pipeline configuration uses the Docker plugin to build and publish Docker images:
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
```yaml
pipeline:
docker:
image: plugins/docker
username: kevinbacon
password: pa55word
email: kevin.bacon@mail.com
repo: foo/bar
tags: latest
```
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
Example configuration using multiple tags:
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
```diff
pipeline:
docker:
image: plugins/docker
repo: foo/bar
- tags: latest
+ tags:
+ - latest
+ - 1.0.1
+ - 1.0
```
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
Example configuration using build arguments:
```diff
publish:
docker:
image: plugins/docker
repo: foo/bar
+ build_args:
+ - HTTP_PROXY=http://yourproxy.com
2016-07-22 22:53:09 +00:00
```
2016-12-14 17:29:50 +00:00
Example configuration using alternate Dockerfile:
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
```diff
publish:
docker:
image: plugins/docker
repo: foo/bar
- dockerfile: Dockerfile
+ dockerfile: path/to/Dockerfile
2016-07-22 22:53:09 +00:00
```
2016-12-14 17:29:50 +00:00
Example configuration using a custom registry:
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
```diff
pipeline:
docker:
image: plugins/docker
- repo: foo/bar
+ repo: index.company.com/foo/bar
+ registry: index.company.com
```
2016-07-22 22:53:09 +00:00
2016-12-14 17:29:50 +00:00
Example configuration using inline credentials:
2015-05-15 00:11:26 +00:00
2016-12-14 17:29:50 +00:00
```diff
2016-07-22 22:53:09 +00:00
pipeline:
2015-05-15 00:11:26 +00:00
docker:
2016-08-19 20:07:19 +00:00
image: plugins/docker
2016-12-14 17:29:50 +00:00
+ username: kevinbacon
+ password: pa55word
repo: foo/bar
```
# Secrets
The Docker plugin supports reading credentials from the Drone secret store. This is strongly recommended instead of storing credentials in the pipeline configuration in plain text.
```diff
pipeline:
docker:
image: plugins/docker
- username: kevinbacon
- password: pa55word
2015-05-15 00:11:26 +00:00
repo: foo/bar
2015-09-03 05:14:15 +00:00
```
2016-12-14 17:29:50 +00:00
Use the command line utility to add secrets to the store:
```nohighlight
drone secret add --image=plugins/docker \
octocat/hello-world DOCKER_USERNAME kevinbacon
drone secret add --image=plugins/docker \
octocat/hello-world DOCKER_PASSWORD pa55word
```
Don't forget to sign the Yaml after making changes:
```nohighlight
drone sign octocat/hello-world
```
# Secret Reference
DOCKER_USERNAME
: docker registry username
DOCKER_PASSWORD
: docker registry password
DOCKER_EMAIL
: docker registry email
# Parameter Reference
registry
: authenticates to this registry
username
: authenticates with this username
password
: authenticates with this password
email
: authenticates with this email
repo
: repository name for the image
tags
: repository tag for the image
dockerfile
: dockerfile to be used, defaults to Dockerfile
auth
: auth token for the registry
context
: the context path to use, defaults to root of the git repo
force_tag=false
: replace existing matched image tags
insecure=false
: enable insecure communication to this registry
mirror
: use a mirror registry instead of pulling images directly from the central Hub
bip=false
: use for pass bridge ip
dns
: set custom dns servers for the container
storage_driver
: supports `aufs` , `overlay` or `vfs` drivers
build_args
: custom arguments passed to docker build