# AddVolume

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

Adds a volume mount to a generated Docker Compose service.

## Definition

```go
func (Service) AddVolume(
    source string,
    target string,
    options ...*ServiceAddVolumeOptions,
) Service
```

## Parameters

- `source` (`string`) -- The source volume name or host path.
- `target` (`string`) -- The target path inside the container.
- `options` (`...*ServiceAddVolumeOptions`) -- optional settings, see [Options](#options)

## Options

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

- `Type` (`*string`) -- The Docker Compose volume type, such as `volume` or `bind`.
- `IsReadOnly` (`*bool`) -- A value indicating whether the volume is mounted as read-only.
- `Configure` (`func(obj Volume)`) `callback` -- An optional callback for further volume customization.

## Returns

[`Service`](/reference/api/go/aspire.hosting.docker/service.md) -- The updated Docker Compose service.

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

## Applies to

- [`Service`](/reference/api/go/aspire.hosting.docker/service.md)
