Docker compose files
Environment variables
You can pass your own environment variables into your docker-compose file - for more details see Environment variables.
A standard docker0s app provides the following environment variables:
ENV_FILEPath to the combined env file on the host
ASSETS_PATHPath to the assets dir on the host
Assets are resources pushed to the server as part of the docker0s deployment - config files, scripts, media etc.
STORE_PATHPath to the store dir on the host
The store is for files created by the containers - logs, databases, uploads etc.
Example usage in your docker-compose.yml:
services:
postgres:
image: postgres:latest
restart: unless-stopped
env_file: "${ENV_FILE}"
volumes:
- "${STORE_PATH}/db:/db"
- "${ASSET_PATH}/scripts:/scripts"
Compose templates
If the docker-compose file ends in a .jinja2 extension, docker0s will treat it as a
Jinja2 template. See the Jinja documentation
for details of the template syntax.
The template will be able to reference other documents relative to it, regardless of
whether it is a local file or a remote file on a git+... url.
The template is rendered with the context dict provided in compose_context, plus the
following values:
hostA reference to the instantiated Host object.
Example usage in a template:
services: my_service: environment: domain: {{ host.name }}
envA reference to the fully resolved environment variables that will be sent to the server. It is recommended to prefer environment variable substitution (eg
${env_var}) as it allows more flexibility when working on the server in the future, but theenvcontext variable can be useful for conditional statements.Example usage in a template:
services: my_service: environment: {% if env.domain %} domain: ${domain} {% endif %}appsA reference to the compose template contexts of other apps in the current manifest. Note that this includes
envand the other context variables mentioned here.App names are normalised, so can be specified as described in App naming, eg
apps.MyApp,apps.my_appetcExample usage in a template:
services: my_service: {% if smtp_relay in apps %} networks: - {{ apps.smtp_relay.network }} {% endif %}docker0s,globalsReserved for future use.
Take care not to use these variables in your own compose_context.