# AddService

- Module: [Aspire.Hosting.Docker](/reference/api/go/aspire.hosting.docker.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`ComposeFile`](/reference/api/go/aspire.hosting.docker/composefile.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Adds a service definition to the Docker Compose file.

## Definition

```go
func (ComposeFile) AddService(
    name string,
    options ...*AddServiceOptions,
) ComposeFile
```

## Parameters

- `name` (`string`) -- The name of the service.
- `options` (`...*AddServiceOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*AddServiceOptions` argument.

- `Image` (`*string`) -- The container image to use for the service.
- `Configure` (`func(obj Service)`) `callback` -- An optional callback for further service customization.

## Returns

[`ComposeFile`](/reference/api/go/aspire.hosting.docker/composefile.md) -- The updated Docker Compose file.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`ComposeFile`](/reference/api/go/aspire.hosting.docker/composefile.md)
