Skip to main content

Compose

You might be familiar with docker-compose.yml files, now known as the Compose specification and compose.yaml files. It's a simple way to define and run multi-container Docker applications. Defang allows you to use compose.yaml files to deploy your application to the cloud.

How it works

You can define your services using a compose.yaml file in the root of your project, or use the defang generate command to generate one (along with other resources). This file is used to define your application's services and how they run. You can edit this file to add more services or change the configuration of existing services.

When you run defang compose up, Defang will read your compose.yaml file and deploy the services named in that file to the cloud.

Service Name Resolution

One thing to keep in mind is that, at the time of this writing, Defang identifies services by the user/account name and the service name (as defined in the compose.yaml file). This means that if you have multiple Defang projects with the same service name, they will conflict with each other. We plan to provide a more robust system for managing service names and protecting against conflicts in the future.

Configuration

If you have a service that depends on a secret like an api key, you can set that secret using the CLI:

defang config set --name MY_API_KEY

and then connect it to the service by specifying it in the compose.yaml:

services:
my-service:
secrets:
- MY_API_KEY

secrets:
MY_API_KEY:
external: true
Configuration & Secrets

Read more about configuration in the configuration page.