# 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/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/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/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Publishing/ComposeServiceInfo.cs)

Gets the target port inside the container.

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