# RestartPolicy

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

Defines the restart policy for a Docker service in a Swarm cluster.

## Definition

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

public sealed class RestartPolicy
{
    // ...
}
```

## Remarks

This class specifies the conditions, delay, maximum attempts, and time window involved in restarting a Docker service container within a Swarm deployment.

## Constructors

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

## Properties

- [Condition](/reference/api/csharp/aspire.hosting.docker/restartpolicy/properties.md#condition) : `string?` `get; set` -- Specifies the condition under which a service's container will be restarted.
- [Delay](/reference/api/csharp/aspire.hosting.docker/restartpolicy/properties.md#delay) : `string?` `get; set` -- Specifies the delay duration between restart attempts of the service container.
- [MaxAttempts](/reference/api/csharp/aspire.hosting.docker/restartpolicy/properties.md#maxattempts) : `int?` `get; set` -- Specifies the maximum number of restart attempts allowed for a container as part of the restart policy.
- [Window](/reference/api/csharp/aspire.hosting.docker/restartpolicy/properties.md#window) : `string?` `get; set` -- Defines the time window for evaluating the restart conditions in a Docker service restart policy.
