# ComposeFile

- Module: [Aspire.Hosting.Docker](/reference/api/typescript/aspire.hosting.docker.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

Represents a Docker Compose file with properties and configurations for services, networks, volumes, secrets, configs, and custom extensions.

## Definition

```typescript
interface ComposeFile {
  configs: Dict<string,Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ComposeNodes.Config>;
  extensions: Dict<string,any>;
  name: string;
  networks: Dict<string,Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ComposeNodes.Network>;
  secrets: Dict<string,Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ComposeNodes.Secret>;
  services: Dict<string,Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ComposeNodes.Service>;
  version: string;
  volumes: Dict<string,Aspire.Hosting.Docker/Aspire.Hosting.Docker.Resources.ServiceNodes.Volume>;
  addConfig(name: string, file?: string, content?: string, external?: boolean, configure?: (obj: Config) => Promise<void>): ComposeFile;
  addNetwork(name: string, driver?: string, external?: boolean, configure?: (obj: Network) => Promise<void>): ComposeFile;
  addSecret(name: string, file?: string, external?: boolean, configure?: (obj: Secret) => Promise<void>): ComposeFile;
  addService(name: string, image?: string, configure?: (obj: Service) => Promise<void>): ComposeFile;
  addVolume(name: string, driver?: string, external?: boolean, configure?: (obj: Volume) => Promise<void>): ComposeFile;
}
```

## Properties

- `configs`: `Config>` `get - set` -- Represents a collection of configuration objects within a Docker Compose file. Each key in the dictionary corresponds to a configuration name, and the value is an instance of the `Config` class that contains the associated configuration details.
- `extensions`: `Dict<string,any>` `get - set` -- Represents a collection of user-defined extension fields that can be added to the Compose file. These extensions are represented as a dictionary where the key is a string identifier for the extension, and the value is an object that holds the custom data relevant to the extension. This allows flexibility for including additional metadata or configuration outside the scope of standard Compose file specifications.
- `name`: `string` `get - set` -- Represents the name of the Docker Compose file or project.
- `networks`: `Network>` `get - set` -- Represents the collection of networks defined in a Docker Compose file.
- `secrets`: `Secret>` `get - set` -- Represents the secrets section in a Docker Compose file. Contains a collection of secret definitions used within the Compose file.
- `services`: `Service>` `get - set` -- Represents a collection of services defined in a Docker Compose file. Each service is identified by a unique name and contains configuration details as defined by the `Service` class.
- `version`: `string` `get - set` -- Represents the version of the Docker Compose file format being used. This property specifies the format of the Compose file and determines the supported features and behaviors.
- `volumes`: `Volume>` `get - set` -- Represents a collection of volume definitions within a Docker Compose file.

## Methods

- [addConfig](/reference/api/typescript/aspire.hosting.docker/composefile/addconfig.md) -- `method` -- Adds a top-level config definition to the Docker Compose file.
    ```typescript
  addConfig(name: string, file?: string, content?: string, external?: boolean, configure?: (obj: Config) => Promise<void>): ComposeFile
  ```
- [addNetwork](/reference/api/typescript/aspire.hosting.docker/composefile/addnetwork.md) -- `method` -- Adds a top-level network definition to the Docker Compose file.
    ```typescript
  addNetwork(name: string, driver?: string, external?: boolean, configure?: (obj: Network) => Promise<void>): ComposeFile
  ```
- [addSecret](/reference/api/typescript/aspire.hosting.docker/composefile/addsecret.md) -- `method` -- Adds a top-level secret definition to the Docker Compose file.
    ```typescript
  addSecret(name: string, file?: string, external?: boolean, configure?: (obj: Secret) => Promise<void>): ComposeFile
  ```
- [addService](/reference/api/typescript/aspire.hosting.docker/composefile/addservice.md) -- `method` -- Adds a service definition to the Docker Compose file.
    ```typescript
  addService(name: string, image?: string, configure?: (obj: Service) => Promise<void>): ComposeFile
  ```
- [addVolume](/reference/api/typescript/aspire.hosting.docker/composefile/addvolume.md) -- `method` -- Adds a top-level volume definition to the Docker Compose file.
    ```typescript
  addVolume(name: string, driver?: string, external?: boolean, configure?: (obj: Volume) => Promise<void>): ComposeFile
  ```
