# ComposeServicePort Properties

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [ComposeServicePort](/reference/api/csharp/aspire.hosting/composeserviceport.md)
- Kind: `Properties`
- Members: `2`

Represents a port mapping for a compose service.

## PublishedPort

- Name: `PublishedPort`
- Modifiers: `nullable` `get; init`
- Returns: `int?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/a3766e994fd2cba86c8ac60b8a80268cab7e6383/src/Aspire.Hosting/Publishing/ComposeServiceInfo.cs)

Gets the port published on the host.

```csharp
public int? PublishedPort { get; init; }
```

## TargetPort

- Name: `TargetPort`
- Modifiers: `nullable` `get; init`
- Returns: `int?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/a3766e994fd2cba86c8ac60b8a80268cab7e6383/src/Aspire.Hosting/Publishing/ComposeServiceInfo.cs)

Gets the target port inside the container.

```csharp
public int? TargetPort { get; init; }
```
