4.0 KiB
Use the Docker plugin to build and push Docker images to a registry. The following parameters are used to configure this plugin:
registry
- authenticates to this registryusername
- authenticates with this usernamepassword
- authenticates with this passwordemail
- authenticates with this emailrepo
- repository name for the imagetag
- repository tag for the imagefile
- dockerfile to be used, defaults to Dockerfilecontext
- the context path to use, defaults to root of the git repoinsecure
- enable insecure communication to this registrymirror
- use a mirror registry instead of pulling images directly from the central Hubbip
- use for pass bridge ipdns
- set custom dns servers for the containerstorage_driver
- useaufs
,devicemapper
,btrfs
oroverlay
driverstorage_path
- location of docker daemon storage on diskbuild_args
- build arguments to pass todocker build
The following is a sample Docker configuration in your .drone.yml file:
publish:
docker:
username: kevinbacon
password: pa55word
email: kevin.bacon@mail.com
repo: foo/bar
tag: latest
file: Dockerfile
insecure: false
Publish and image with multiple tags:
publish:
docker:
username: kevinbacon
password: pa55word
email: kevin.bacon@mail.com
repo: foo/bar
tag:
- latest
- 1.0.1
- "1.0"
Build an image with arguments:
publish:
docker:
username: kevinbacon
password: pa55word
email: kevin.bacon@mail.com
repo: foo/bar
build_args:
- HTTP_PROXY=http://yourproxy.com
Caching
The Drone build environment is, by default, ephemeral meaning that you layers are not saved between builds. There are two methods for caching your layers.
Graph directory caching
This is the preferred method when using the overlay
or aufs
storage drivers. Just use Drone's caching feature to backup and restore the directory /drone/docker
, as shown in the following example:
publish:
docker:
storage_path: /drone/docker
username: kevinbacon
password: pa55word
email: kevin.bacon@mail.com
repo: foo/bar
tag:
- latest
- "1.0.1"
cache:
mount:
- /drone/docker
Troubleshooting
For detailed output you can set the DOCKER_LAUNCH_DEBUG
environment variable in your plugin configuration. This starts Docker with verbose logging enabled.
publish:
docker:
environment:
- DOCKER_LAUNCH_DEBUG=true
Known Issues
There are known issues when attempting to run this plugin on CentOS, RedHat, and Linux installations that do not have a supported storage driver installed. You can check by running docker info | grep 'Storage Driver:'
on your host machine. If the storage driver is not aufs
or overlay
you will need to re-configure your host machine.
This error occurs when trying to use the default aufs
storage Driver but aufs is not installed:
level=fatal msg="Error starting daemon: error initializing graphdriver: driver not supported
This error occurs when trying to use the overlay
storage Driver but overlay is not installed:
level=error msg="'overlay' not found as a supported filesystem on this host.
Please ensure kernel is new enough and has overlay support loaded."
level=fatal msg="Error starting daemon: error initializing graphdriver: driver not supported"
This error occurs when using CentOS or RedHat which default to the devicemapper
storage driver:
level=error msg="There are no more loopback devices available."
level=fatal msg="Error starting daemon: error initializing graphdriver: loopback mounting failed"
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
The above issue can be resolved by setting storage_driver: vfs
in the .drone.yml
file. This may work, but will have very poor performance as discussed here.