Your company here ā€” click to reach over 10,000 unique daily visitors

ocf_heartbeat_docker - Man Page

Docker container resource agent.


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


The docker HA resource agent creates and launches a docker container based off a supplied docker image. Containers managed by this agent are both created and removed upon the agent's start and stop actions.

Supported Parameters


The docker image to base this container off of.

(required, string, no default)


The name to give the created container. By default this will be that resource's instance name.

(optional, string, no default)


Allow the image to be pulled from the configured docker registry when the image does not exist locally. NOTE, this can drastically increase the time required to start the container if the image repository is pulled over the network.

(optional, boolean, no default)


Add options to be appended to the 'docker run' command which is used when creating the container during the start action. This option allows users to do things such as setting a custom entry point and injecting environment variables into the newly created container. Note 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)


Specify a command to launch within the container once it has initialized.

(optional, string, no default)


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)


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.

(optional, string, no default)


Kill a container immediately rather than waiting for it to gracefully shutdown

(optional, boolean, no default)


Allow the container to be reused once it is 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 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.

(optional, boolean, no default)

Supported Actions

This resource agent supports the following actions (operations):


Starts the resource. Suggested minimum timeout: 90s.


Stops the resource. Suggested minimum timeout: 90s.


Performs a detailed status check. Suggested minimum timeout: 30s. Suggested interval: 30s.


Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5s.


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



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


04/26/2024 resource-agents UNKNOWN OCF resource agents