Skip to content
Docs Try Aspire

RestartPolicy Properties

Class Properties 4 members
Defines the restart policy for a Docker service in a Swarm cluster.
Condition Section titled Condition nullable string?
Specifies the condition under which a service's container will be restarted.
public string? Condition { get; set; }
This property determines the criteria for restarting a container. Possible values may include "none", "on-failure", or "any", which dictate when a restart should happen (e.g., never, only on failures, or always).
Delay Section titled Delay nullable string?
Specifies the delay duration between restart attempts of the service container.
public string? Delay { get; set; }
The delay defines the time interval to wait before attempting to restart a service container after a failure. It is expressed as a time duration string (e.g., "5s" for 5 seconds).
MaxAttempts Section titled MaxAttempts nullable int?
Specifies the maximum number of restart attempts allowed for a container as part of the restart policy.
public int? MaxAttempts { get; set; }
Defines the upper limit for how many times Docker will attempt to restart the container before giving up. If not set, the system default behavior or an unlimited restart attempts policy may be applied. This setting is useful for handling scenarios where a service is repeatedly failing and prevents infinite restart loops.
Window Section titled Window nullable string?
Defines the time window for evaluating the restart conditions in a Docker service restart policy.
public string? Window { get; set; }
This property specifies the duration (e.g., in seconds or any supported time format) during which restart attempts are counted towards the maximum attempts allowed. If the service exits and restarts within this specified window, it contributes to the count of restart attempts under the restart policy.