# AddNetwork

- 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 top-level network definition to the Docker Compose file.

## Definition

```go
func (ComposeFile) AddNetwork(
    name string,
    options ...*AddNetworkOptions,
) ComposeFile
```

## Parameters

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

## Options

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

- `Driver` (`*string`) -- The network driver to use.
- `External` (`*bool`) -- A value indicating whether the network is managed outside the generated Compose file.
- `Configure` (`func(obj Network)`) `callback` -- An optional callback for further network 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)
