Skip to content
Calcrivo

Docker Restart Policy Estimator

Estimate container restart counts and backoff delays under different restart policies.

Inputs

crashes/hour

Expected crash rate without restart limits.

retries

Maximum restart attempts (on-failure:N policy).

seconds

Docker's initial restart delay (doubles each attempt).

hours

Time window to project restart behavior over.

Restart Count

5

Total Backoff Delay

31.0seconds

Max Single Restart Delay

16.0seconds

Expected Crashes in Window

72.0

Step by step

  1. Expected crashes in window

    3/h × 24h

    = 72.0

  2. Actual restarts (capped by policy)

    min(72.0, 5)

    = 5

  3. Total backoff time (exponential)

    1s × (2^5 − 1)

    = 31.0s

How it works

Docker's restart backoff doubles with each attempt: delay(n) = initialBackoff × 2^(n−1). Total backoff = initialBackoff × (2^restarts − 1). The on-failure:N policy caps restarts, preventing infinite crash loops from consuming resources.

Formula

Total Backoff

totalBackoff = initialBackoff × (2^restarts − 1)

initialBackoff
Initial delay in seconds
restarts
Number of restart attempts

Frequently Asked Questions

What's the difference between 'always' and 'on-failure'?

'always' restarts regardless of exit code (even clean exits); 'on-failure:N' only restarts on non-zero exit codes, up to N times, preventing infinite loops from application bugs.

Does Docker cap the backoff delay?

Docker caps the backoff at a platform-specific maximum (typically around 2 minutes on recent versions), preventing extremely long delays after many restarts.

You might also need