# Service.AddVolume

- Module: [Aspire.Hosting.Docker](/reference/api/go/aspire.hosting.docker.md)
- Defined on: [Service](/reference/api/go/aspire.hosting.docker/service.md)
- Version: `17.0.0`
- Kind: `method`

Adds a volume mount to a generated Docker Compose service.

## Definition

```go
type Service interface {
    // ... omitted for brevity
    AddVolume(
        source string,
        target string,
        options ...*ServiceAddVolumeOptions,
    ) Service
}
```

## Signature

```go
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()`.

## Defined on

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