Skip to content

feat: retry Docker connection on startup with backoff #523

@CybotTM

Description

@CybotTM

Context

Reported in #522 — when using a Docker Socket Proxy (or any TCP-based Docker host), ofelia fails to start if Docker isn't immediately reachable. The daemon pings Docker exactly once at startup and exits fatally if it fails.

This affects all TCP-based setups: socket proxies, remote Docker hosts, Docker-in-Docker.

Current Behavior

  1. initDockerHandler() calls provider.Ping() once
  2. If the ping fails (30s dial timeout), the daemon exits with "SDK provider failed to connect to Docker: pinging docker"
  3. No retry, no backoff, no configuration option to wait

Relevant code: cli/docker_config_handler.go lines 178-180 and 129-132.

Proposed Behavior

Add retry with exponential backoff on the initial Docker connection:

  • Default: 5 retries, 1s → 2s → 4s → 8s → 16s backoff (total ~31s)
  • Configurable via --docker-retry-count / OFELIA_DOCKER_RETRY_COUNT and --docker-retry-interval / OFELIA_DOCKER_RETRY_INTERVAL
  • Log each retry attempt at WARN level
  • Keep the current behavior as default (retry count = 0 means no change)

Workarounds

Users can currently work around this with:

  • depends_on + condition: service_healthy in Docker Compose
  • restart: unless-stopped on the ofelia container

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions