Skip to content

Proposal - Application-defined "alive probe" #21142

@icecrime

Description

@icecrime

Problem statement

Docker currently doesn't provide any built-in way to determine if a container is "alive" in the sense that the service it provides is up and running. This is useful in many scenarios, for example:

This issue cover the support for "alive probes" at the Engine level.

Proposal

Every container would support one optional container-specific probe to determine whether a service is alive. This would translate in docker UX through several new command line options for the run sub-command (naming to be discussed):

Option Default value Description
--probe "" URI of an HTTP endpoint or in-container script to probe for service liveliness
--probe-interval 60 Interval in seconds between probes
--probe-retry 1 Number of successive probe failures before considering the container failing
--probe-timeout TBD Number of seconds for the probe run before failure is assumed
--probe-grace TBD Number of seconds since container start time before the probe is active

A container is considered alive when the probe returns 0 for a file:// based probe, or a status code in the 200-399 range for an http[s]:// based probe.

Examples:

docker run -d \
           --probe="file:///some/script.sh" \
           --probe-interval=120 myimage

Open questions

Implementation

  • Should it be a new value for the container state, or should it be a new field in the container definition?
  • Should probe failure be reported in the events API?

Restart policies

  • Should we back restart policies on the probe result?
  • Can we implicitly alter the behavior of --restart=always and --restart=on-failure when a --probe is specified? That is roughly equivalent to assuming that the restart policy was always backed by a default probe which behavior is to look for the container process being alive.

References

Ping @crosbymichael @tonistiigi @mgoelzer @aluzzardi @ehazlett

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions