diff --git a/docs/docs/20-usage/60-services.md b/docs/docs/20-usage/60-services.md index c0a95086d..62039fe36 100644 --- a/docs/docs/20-usage/60-services.md +++ b/docs/docs/20-usage/60-services.md @@ -1,6 +1,10 @@ # Services -Woodpecker provides a services section in the YAML file used for defining service containers. The below configuration composes database and cache containers. +Woodpecker provides a services section in the YAML file used for defining service containers. +The below configuration composes database and cache containers. + +Services are accessed using custom hostnames. +In the example below, the MySQL service is assigned the hostname `database` and is available at `database:3306`. ```diff pipeline: @@ -18,8 +22,6 @@ services: image: redis ``` -Services are accessed using custom hostnames. In the above example the mysql service is assigned the hostname `database` and is available at `database:3306`. - ## Configuration Service containers generally expose environment variables to customize service startup such as default usernames, passwords and ports. Please see the official image documentation to learn more. @@ -77,3 +79,21 @@ services: database: image: mysql ``` + +## Complete Pipeline Example + +```yml +services: + database: + image: mysql + environment: + - MYSQL_DATABASE=test + - MYSQL_ROOT_PASSWORD=example +pipeline: + get-version: + image: ubuntu + commands: + - ( apt update && apt dist-upgrade -y && apt install -y mysql-client 2>&1 )> /dev/null + - sleep 30s # need to wait for mysql-server init + - echo 'SHOW VARIABLES LIKE "version"' | mysql -uroot -hdatabase test -pexample +```