# Volume Properties

- Package: [Aspire.Hosting.Docker](/reference/api/csharp/aspire.hosting.docker.md)
- Type: [Volume](/reference/api/csharp/aspire.hosting.docker/volume.md)
- Kind: `Properties`
- Members: `8`

Represents a volume definition in a Docker Compose configuration file.

## Driver

- Name: `Driver`
- Modifiers: `nullable` `get; set`
- Returns: `string?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

Gets or sets the name of the driver used for the volume. The driver is responsible for managing the volume and its storage backend.

```csharp
public string? Driver { get; set; }
```

## DriverOpts

- Name: `DriverOpts`
- Modifiers: `get; set`
- Returns: `Dictionary<string, string>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

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.

```csharp
public Dictionary<string, string> DriverOpts { get; set; }
```

## External

- Name: `External`
- Modifiers: `nullable` `get; set`
- Returns: `bool?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

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.

```csharp
public bool? External { get; set; }
```

## Labels

- Name: `Labels`
- Modifiers: `get; set`
- Returns: `Dictionary<string, string>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

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.

```csharp
public Dictionary<string, string> Labels { get; set; }
```

## ReadOnly

- Name: `ReadOnly`
- Modifiers: `nullable` `get; set`
- Returns: `bool?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

Gets or sets a value indicating whether the volume is mounted as read-only.

```csharp
public bool? ReadOnly { get; set; }
```

## Remarks

When set to true, the volume will be mounted with read-only permissions, preventing modification of the data within the container. This is commonly used to enforce data immutability for certain use cases.

## Source

- Name: `Source`
- Modifiers: `nullable` `get; set`
- Returns: `string?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

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.

```csharp
public string? Source { get; set; }
```

## Target

- Name: `Target`
- Modifiers: `nullable` `get; set`
- Returns: `string?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

Gets or sets the target path inside the container where the volume is mounted. This specifies the container location for the volume's data.

```csharp
public string? Target { get; set; }
```

## Type

- Name: `Type`
- Modifiers: `nullable` `get; set`
- Returns: `string?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Docker/Resources/ServiceNodes/Volume.cs)

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.

```csharp
public string? Type { get; set; }
```
