Docker Compose
If you are using Docker Compose
based deployments, you need to understand how Docker Compose works with Coolify.
In all cases the Docker Compose (docker-compose.y[a]ml
) file is the single source of truth.
Defining environment variables
Coolify will notice the environment variables you mention in your compose file and will display it in its UI.
Coolify’s magic environment variables
Additionally, Coolify can generate some dynamic environment variables for you.
The syntax is SERVICE_<TYPE>_<IDENTIFIER>
.
Type may be one of:
- FQDN: This will generate an FQDN for the service. The example below shows how you can add paths and ports.
- URL: Generates an URL based on the FQDN you have defined.
- USER: Generates a random string using
Str::random(16)
. You might want to use it as a username in your service. - PASSWORD: Generates a password using
Str::password(symbols: false)
. UsePASSWORD_64
to generate a 64 bit long password withStr::password(length: 64, symbols: false)
. - BASE64: Generates a random string using
Str::random(32)
. For longer strings, useBASE64_64
orBASE64_128
. - REALBASE64: Encodes a randomly generated string using
base64_encode(Str::random(32))
. For longer strings, useREALBASE64_64
orREALBASE64_128
.
Every generated variable can be reused and will always have the same value for every service. All generated variables are displayed in Coolify’s UI for environment variables and can be edited there (except FQDN and URl).
As an example, imagine an application with UUID vgsco4o
(generated by Coolify on creation).
It uses a compose file deploying Appwrite on the wildcard domain http://example.com
.
Storage
You can predefine storage normally in your compose file, but there are a few extra options that you can set to tell Coolify what to do with the storage.
Create an empty directory
Create a file with content
Here you can see how to add a file with content and a dynamic value that is coming from an environment variable.
Exclude from healthchecks
If you have a service that you do not want to be part of your overall healthchecks, you can exclude it from the healthchecks by setting the exclude_from_hc
option to true
.
Connect to Predefined Networks
By default, each compose stack is deployed to a separate network, with the name of your resource uuid. This will allow to each service in your stack to communicate with each other.
But in some cases, you would like to communicate with other resources in your account. For example, you would like to connect your application to a database, which is deployed in another stack.
To do this you need to enable Connect to Predefined Network
option on your Service Stack
page, but this will make the internal Docker DNS not work as expected.
Here is an example. You have a stack with a postgres
database and a laravel
application. Coolify will rename your postgres
stack to postgres-<uuid>
and your laravel
stack to laravel-<uuid>
to prevent name collisions.
If you set Connect to Predefined Network
option on your laravel
stack, your laravel
application will be able to connect to your postgres
database, but you need to use the postgres-<uuid>
as your database host.
Raw Docker Compose Deployment
You can set with docker compose build pack to deploy your compose file directly without most of Coolify’s magic. It is called Raw Compose Deployment
.
Labels
Coolify will still add the following labels (if they are not set) to your application:
To use Coolify’s Proxy (Traefik), you need to set the following labels to your application: