# Volume

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

Represents a volume definition in a Docker Compose configuration file.

## Definition

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

public sealed class Volume
    : Aspire.Hosting.Docker.Resources.ComposeNodes.NamedComposeMember
{
    // ...
}
```

## ATS metadata

### ATS export

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

## Remarks

The [Volume](/reference/api/csharp/aspire.hosting.docker/volume.md) class is used to define properties and options for volumes in a Docker environment. Volumes are used to persist data beyond the lifecycle of a container and can be shared among multiple containers.

## Constructors

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

## Properties

- [Driver](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#driver) : `string?` `get; set` -- Gets or sets the name of the driver used for the volume. The driver is responsible for managing the volume and its storage backend.
- [DriverOpts](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#driveropts) : `Dictionary<string, string>` `get; set` -- Represents a collection of driver-specific options for the volume. These options are passed as key-value pairs to the volume driver, allowing customization or configuration specific to the driver being used.
- [External](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#external) : `bool?` `get; set` -- Indicates whether the volume is external to the current scope or environment. A value of `true` specifies that the volume is managed outside the scope of the current application or configuration. A value of `false`, or a null value, indicates that the volume is managed internally or by default behavior.
- [Labels](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#labels) : `Dictionary<string, string>` `get; set` -- Gets or sets a dictionary of labels associated with the volume. Labels are key-value pairs that can be used for metadata purposes or for organizing and identifying volumes within Docker services.
- [ReadOnly](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#readonly) : `bool?` `get; set` -- Gets or sets a value indicating whether the volume is mounted as read-only.
- [Source](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#source) : `string?` `get; set` -- Gets or sets the source property of the volume. The source defines the location on the host system or the specific resource from which the volume is sourced.
- [Target](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#target) : `string?` `get; set` -- Gets or sets the target path inside the container where the volume is mounted. This specifies the container location for the volume's data.
- [Type](/reference/api/csharp/aspire.hosting.docker/volume/properties.md#type) : `string?` `get; set` -- Gets or sets the type of volume. This specifies the method of volume provisioning such as bind mounts, named volumes, or other supported volume types in Docker.
