ContainerHealthcheck Class
Overrides the healthcheck an image declares (HEALTHCHECK), or disables it.
public sealed class ContainerHealthcheckRemarks
Apple's container runtime has no healthcheck, and rejects a definition that sets one.
Constructors
| Name | Description |
|---|---|
| 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.csInitializes a new instance of the ContainerHealthcheck class that runs an executable without a shell (CMD).
public ContainerHealthcheck(IEnumerable<string> command)Parameters
commandIEnumerable<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.csInitializes a new instance of the ContainerHealthcheck class that runs a command through the shell of the container (CMD-SHELL).
public ContainerHealthcheck(string shellCommand)Parameters
shellCommandstring- The command, run with
/bin/sh -c. The container is healthy when it exits with code 0.
Properties
| Name | Description |
|---|---|
| Command | Gets the executable and the arguments the healthcheck runs, or null when it runs ContainerHealthcheck.ShellCommand or is disabled. |
| Disabled | Gets a healthcheck that disables the one the image declares. |
| Interval | Gets the time between two checks. null keeps the default of the runtime. |
| IsDisabled | Gets a value indicating whether this healthcheck disables the one the image declares. |
| Retries | Gets the number of consecutive failures that make the container unhealthy. null keeps the default of the runtime. |
| ShellCommand | Gets the command run through the shell of the container, or null when the healthcheck runs ContainerHealthcheck.Command or is disabled. |
| StartPeriod | Gets the time the container is given to start, during which failed checks do not count. null keeps the default of the runtime. |
| Timeout | Gets the time a check may run before it is considered failed. null keeps the default of the runtime. |
Command
ContainerHealthcheck.csGets the executable and the arguments the healthcheck runs, or null when it runs ContainerHealthcheck.ShellCommand or is disabled.
public IReadOnlyList<string>? Command { get; }Property value
Disabled
ContainerHealthcheck.csGets a healthcheck that disables the one the image declares.
public static ContainerHealthcheck Disabled { get; }Property value
Interval
ContainerHealthcheck.csIsDisabled
ContainerHealthcheck.csRetries
ContainerHealthcheck.csShellCommand
ContainerHealthcheck.csGets the command run through the shell of the container, or null when the healthcheck runs ContainerHealthcheck.Command or is disabled.
public string? ShellCommand { get; }