Pass environment variables and commands for services

When using services in the Docker runner I’d like to inject environment variables and override command and entrypoint arguments. This is for example required when running a service like Postgres which requires POSTGRES_PASSWORD to be set.

https://hub.docker.com/_/postgres

POSTGRES_PASSWORD

This environment variable is required for you to use the PostgreSQL image. It must not be empty or undefined. This environment variable sets the superuser password for PostgreSQL. The default superuser is defined by the POSTGRES_USER environment variable.

I’ve found that services might have the same definition as steps in the source code. I’ll try to pass the same parameters.

here is an example postgres configuration in the docs that you may find helpful
https://docs.drone.io/pipeline/docker/examples/services/postgres/

Nice, thanks!

It would be useful to include an example on the services landing page that demonstrates how to override environment variables and commands.

https://docs.drone.io/pipeline/docker/syntax/services/

On a side note: does a service inherit the root environment configuration? Is it shared between all services? e.g is it possible to:

---
kind: pipeline
type: docker
name: default

environment:
  POSTGRES_PASSWORD: hello

services:
  - name: postgres
    image: postgres:11

This is useful if both the app and the postgres container share the POSTGRES_PASSWORD variable.