Services

The top-level services section configures containers that should be started in detached mode at the begining of your pipeline. A common use case for services would be when your unit tests require a running redis server, for example:

kind: pipeline
name: default
services:
- name: cache
image: redis

Service container are reachable at a hostname identical to the container name. In our previous example, the redis container name is “cache”, and can be accessed from the pipeine at tcp://redis:6379

It is important to note the service container exit code is ignored, and a non-zero exit code does not fail the overall pipeline. Drone expects service containers to exit with a non-zero exit code, since they often need to be killed after the pipeline completes.

Detached Steps

Services can also be defined directly in the pipeline, as detached pipeline steps. This can be useful when you need direct control over when the service is started, relative to other steps in your pipeline.

entrypoint

Override the default image ENTRYPOINT. The entrypoint of an image is specifies what executable to run when the container starts.

services:
- name: database
image: mysql
entrypoint: [ mysqld ]

environment

Set container environment variables. You can use either an array or a dictionary. Any boolean values; true, false, yes no, need to be enclosed in quotes to ensure they are not converted to True or False by the YML parser.

If the image does not exist, Drone instructs Docker to pull it. If the image is private you will need to configure registry credentials.

privileged

Gives extended privileges to this container. Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host.

services:
- name: docker
image: docker:dind
privileged: true

pull

Instruct Docker to check for a newer version of the image in the remote container registry. If a newer version is available it is automatically downloaded.

volumes

Note that named volumes are supported. If you would like to configure a named volume please consult our detailed volume documentation.

working_dir

Override the default working directory.

services:
- name: server
image: nginx
working_dir: /www

Common Problems

This section highlights some common problems that users encounter when configuring services. If you continue to experience issues please also check the faq. You might also want to compare your yaml to our example service configurations.

Incorrect Hostname

It is import to remember that you cannot use the localhost or 127.0.0.1 address to connect to services from your pipeline. Service containers are assigned their own IP address and hostname. The hostname is based on the service container name.