ContainerHealthcheck Class

Overrides the healthcheck an image declares (HEALTHCHECK), or disables it.

public sealed class ContainerHealthcheck

Remarks

Apple's container runtime has no healthcheck, and rejects a definition that sets one.

Constructors

NameDescription
ContainerHealthcheck(IEnumerable<string>)Initializes a new instance of the ContainerHealthcheck class that runs an executable without a shell (CMD).
ContainerHealthcheck(string)Initializes a new instance of the ContainerHealthcheck class that runs a command through the shell of the container (CMD-SHELL).

ContainerHealthcheck overloads

ContainerHealthcheck(IEnumerable<string>)

ContainerHealthcheck.cs

Initializes a new instance of the ContainerHealthcheck class that runs an executable without a shell (CMD).

public ContainerHealthcheck(IEnumerable<string> command)
Parameters
command IEnumerable<string>
The executable and its arguments. The container is healthy when it exits with code 0.
Remarks

The CLI runtimes only take a shell command, so they run the arguments, quoted, through the shell of the container.

ContainerHealthcheck(string)

ContainerHealthcheck.cs

Initializes a new instance of the ContainerHealthcheck class that runs a command through the shell of the container (CMD-SHELL).

public ContainerHealthcheck(string shellCommand)
Parameters
shellCommand string
The command, run with /bin/sh -c. The container is healthy when it exits with code 0.

Properties

NameDescription
CommandGets the executable and the arguments the healthcheck runs, or null when it runs ContainerHealthcheck.ShellCommand or is disabled.
DisabledGets a healthcheck that disables the one the image declares.
IntervalGets the time between two checks. null keeps the default of the runtime.
IsDisabledGets a value indicating whether this healthcheck disables the one the image declares.
RetriesGets the number of consecutive failures that make the container unhealthy. null keeps the default of the runtime.
ShellCommandGets the command run through the shell of the container, or null when the healthcheck runs ContainerHealthcheck.Command or is disabled.
StartPeriodGets the time the container is given to start, during which failed checks do not count. null keeps the default of the runtime.
TimeoutGets the time a check may run before it is considered failed. null keeps the default of the runtime.

Gets the executable and the arguments the healthcheck runs, or null when it runs ContainerHealthcheck.ShellCommand or is disabled.

public IReadOnlyList<string>? Command { get; }

Gets a healthcheck that disables the one the image declares.

public static ContainerHealthcheck Disabled { get; }

Property value

ContainerHealthcheck

Gets the time between two checks. null keeps the default of the runtime.

public TimeSpan? Interval { get; init; }

Property value

TimeSpan?

Gets a value indicating whether this healthcheck disables the one the image declares.

public bool IsDisabled { get; }

Property value

bool

Gets the number of consecutive failures that make the container unhealthy. null keeps the default of the runtime.

public int? Retries { get; init; }

Property value

int?

Gets the command run through the shell of the container, or null when the healthcheck runs ContainerHealthcheck.Command or is disabled.

public string? ShellCommand { get; }

Property value

string?

Gets the time the container is given to start, during which failed checks do not count. null keeps the default of the runtime.

public TimeSpan? StartPeriod { get; init; }

Property value

TimeSpan?

Gets the time a check may run before it is considered failed. null keeps the default of the runtime.

public TimeSpan? Timeout { get; init; }

Property value

TimeSpan?