# ComposeFile

- Kind: `class`
- Package: [Aspire.Hosting.Docker](/reference/api/csharp/aspire.hosting.docker.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting.Docker.Resources`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ComposeFile.cs)

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

## Definition

```csharp
namespace Aspire.Hosting.Docker.Resources;

public sealed class ComposeFile
{
    // ...
}
```

## ATS metadata

### ATS export

- Type ID: `Aspire.Hosting.Docker/ComposeFile`

## Remarks

This class is designed to encapsulate the structure of a Docker Compose file as a strongly-typed model. It supports serialization to YAML format for usage in Docker Compose operations.

## Constructors

- [ComposeFile](/reference/api/csharp/aspire.hosting.docker/composefile/constructors.md#constructor)

## Properties

- [Configs](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#configs) : `Dictionary<string, 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](/reference/api/csharp/aspire.hosting.docker/config.md) class that contains the associated configuration details.
- [Extensions](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#extensions) : `Dictionary<string, object>` `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](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#name) : `string?` `get; set` -- Represents the name of the Docker Compose file or project.
- [Networks](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#networks) : `Dictionary<string, Network>` `get; set` -- Represents the collection of networks defined in a Docker Compose file.
- [Secrets](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#secrets) : `Dictionary<string, Secret>` `get; set` -- Represents the secrets section in a Docker Compose file. Contains a collection of secret definitions used within the Compose file.
- [Services](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#services) : `Dictionary<string, 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](/reference/api/csharp/aspire.hosting.docker/service.md) class.
- [Version](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#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](/reference/api/csharp/aspire.hosting.docker/composefile/properties.md#volumes) : `Dictionary<string, Volume>` `get; set` -- Represents a collection of volume definitions within a Docker Compose file.

## Methods

- [AddConfig(Config)](/reference/api/csharp/aspire.hosting.docker/composefile/methods.md#addconfig-config) : [ComposeFile](/reference/api/csharp/aspire.hosting.docker/composefile.md) -- Adds a new config entry to the Compose file.
- [AddNetwork(Network)](/reference/api/csharp/aspire.hosting.docker/composefile/methods.md#addnetwork-network) : [ComposeFile](/reference/api/csharp/aspire.hosting.docker/composefile.md) -- Adds a new network to the Compose file.
- [AddService(Service)](/reference/api/csharp/aspire.hosting.docker/composefile/methods.md#addservice-service) : [ComposeFile](/reference/api/csharp/aspire.hosting.docker/composefile.md) -- Adds a new service to the Compose file.
- [AddVolume(Volume)](/reference/api/csharp/aspire.hosting.docker/composefile/methods.md#addvolume-volume) : [ComposeFile](/reference/api/csharp/aspire.hosting.docker/composefile.md) -- Adds a new volume to the Compose file.
- [ToYaml(string)](/reference/api/csharp/aspire.hosting.docker/composefile/methods.md#toyaml-string) : `string` -- Converts the current instance of [ComposeFile](/reference/api/csharp/aspire.hosting.docker/composefile.md) to its YAML string representation.
