OCF_HEARTBEAT_DOCKER(7)

πŸ’– OCF_HEARTBEAT_DOCKER(7) πŸ’–

okay so bestie, this is a page from the OCF resource agents manual set β€” the ocf_heartbeat_docker one β€” and it's literally all about running Docker containers as HA resources. buckle up πŸŽ€


✨ NAME ✨

ocf_heartbeat_docker β€” the Docker container resource agent. that's it, that's the vibe πŸ’…


🌸 SYNOPSIS 🌸

docker [start | stop | monitor | meta-data | validate-all]

πŸ¦‹ DESCRIPTION πŸ¦‹

So the docker HA resource agent literally creates and launches a docker container based off a docker image you hand it. The containers this agent manages are both created and removed on the agent's start and stop actions β€” like, it's not just nudging an existing thing, it's doing the whole lifecycle. periodt ✨


πŸ’œ SUPPORTED PARAMETERS πŸ’œ

  • image β€” the docker image you're basing this container off of. this one's required, it's a string, and there's no default. you gotta give it something, bestie 🫢
  • name β€” the name to give the created container. by default this will be that resource's instance name. (optional, string, no default)
  • allow_pull β€” lets the image be pulled from the configured docker registry when the image doesn't exist locally. ⚠️ NOTE: this can drastically increase the time required to start the container if the image repository is pulled over the network. like, drastically drastically. (optional, boolean, no default) πŸ”₯
  • run_opts β€” adds options that get appended to the docker run command, which is what's used when creating the container during the start action. this one's iconic because it lets users do stuff like setting a custom entry point and injecting environment variables into the newly created container. note that the -d option is supplied regardless of this value, to force containers to run in the background. πŸ‘‘
NOTE: do not explicitly specify the --name argument in the run_opts. this agent will set --name using either the resource's instance or the name provided in the name argument of this agent.

(optional, string, no default)

  • run_cmd β€” specify a command to launch within the container once it has initialized. (optional, string, no default) 🌸
  • mount_points β€” a comma separated list of directories that the container is expecting to use. the agent will ensure they exist by running mkdir -p. (optional, string, no default) πŸ“
  • monitor_cmd β€” specify the full path of a command to launch within the container to check the health of the container. this command must return 0 to indicate that the container is healthy. a non-zero return code will indicate that the container has failed and should be recovered. 😭

If docker exec is supported, it is used to execute the command. If not, nsenter is used.

Note: using this method for monitoring processes inside a container is not recommended, as containerd tries to track processes running inside the container and does not deal well with many short-lived processes being spawned. ensure that your container monitors its own processes and terminates on fatal error rather than invoking a command from the outside. pls. for me. πŸ™ˆ

(optional, string, no default)

  • force_kill β€” kill a container immediately rather than waiting for it to gracefully shutdown. no chill mode, just πŸ’€ (optional, boolean, no default)
  • reuse β€” allow the container to be reused once it's stopped. by default, containers get removed once they are stopped. enable this option to have the particular one persist when this happens. (optional, boolean, default 0)
  • query_docker_health β€” query the builtin healthcheck of docker (v1.12+) to determine health of the container. if left empty or set to false it will not be used. ✨

The healthcheck itself has to be configured within docker, e.g. via HEALTHCHECK in Dockerfile. this option just queries in what condition docker considers the container to be and lets ocf do its thing accordingly. 🧚

Note that the time a container is in "starting" state counts against the monitor timeout. ⏳

This is an additional check besides the standard check for the container to be running, and the optional monitor_cmd check. it doesn't disable or override them, so all of them (if used) have to come back healthy for the container to be considered healthy. no partial credit, bestie 🌈

(optional, boolean, no default)


⭐ SUPPORTED ACTIONS ⭐

This resource agent supports the following actions (operations):

  1. start β€” starts the resource. suggested minimum timeout: 90s.
  2. stop β€” stops the resource. suggested minimum timeout: 90s.
  3. monitor β€” performs a detailed status check. suggested minimum timeout: 30s. suggested interval: 30s.
  4. meta-data β€” retrieves resource agent metadata (internal use only). suggested minimum timeout: 5s.
  5. validate-all β€” performs a validation of the resource configuration. suggested minimum timeout: 30s.

πŸ’– EXAMPLE CRM SHELL πŸ’–

The following is an example configuration for a docker resource using the crm(8) shell:

primitive p_docker ocf:heartbeat:docker \
  params \
    image=string \
  op monitor timeout="30s" interval="30s" depth="0"

πŸŽ€ EXAMPLE PCS πŸŽ€

The following is an example configuration for a docker resource using pcs(8)

pcs resource create p_docker ocf:heartbeat:docker \
  image=string \
  op monitor timeout="30s" interval="30s" OCF_CHECK_LEVEL="0"

πŸ¦‹ SEE ALSO πŸ¦‹

http://clusterlabs.org/ β€” go look, iykyk πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

ClusterLabs contributors (see the resource agent source for information about individual authors) 🫢


okay that's the whole page!! mwah πŸ’‹ this build is resource-agents UNKNOWN and the date on it is 10/01/2026 β€” noted, dated, slayed. go forth and containerize, bestie πŸŒŸπŸ’œ

πŸ“¦ where this page comes from