portainer / portainer

Making Docker and Kubernetes management easy.
https://www.portainer.io
zlib License
30.71k stars 2.46k forks source link

Portainer ignores start_interval attribute in healthcheck of docker-compose yml #11757

Closed tamas-boczan closed 5 months ago

tamas-boczan commented 5 months ago

Before you start please confirm the following.

Problem Description

docker-compose provides an option to periodically run a command which determines the health of the container. The intervals between health-checks are different during the startup period immediately after the container is started, and later.

Corresponding docs here.

I found that when I start stacks with portainer, the start_interval attribute is ignored, and interval is used even during the startup period, despite it working as expected when running docker-compose without portainer.

Expected Behavior

When I start a container with a low start_interval value, and a high interval value, the start_interval value is used in the first startup_period seconds after the container is started.

Actual Behavior

Portainer uses the interval value only, ignoring start_interval. When I directly run the stack with docker compose without Portainer, it works as intended.

Steps to Reproduce

Minimal docker-compose example below. Container second starts when first becomes healthy. The health check test is set to always return that the container is healthy.

Expected: first starts, then second starts 1 second later. This happens when executed directly with docker-compose up. Actual: When executed with Portainer, second starts 60 seconds after first. It's ignored that during the start_period, health checks should happen every start_interval second.

services:
  first:
    image: alpine
    command: ["tail", "-f", "/dev/null"]
    healthcheck:
      test: exit 0
      start_period: 15s
      start_interval: 1s
      interval: 60s

  second:
    image: alpine
    command: ["tail", "-f", "/dev/null"]
    depends_on:
      first:
        condition: service_healthy

Portainer logs or screenshots

screenshot

Portainer version

2.19.5

Portainer Edition

Community Edition (CE)

Platform and Version

Docker 26.1.0 | Docker Compose v2.26.1

OS and Architecture

Debian 12 | ARM64

Browser

No response

What command did you use to deploy Portainer?

No response

Additional Information

No response

EDIT: typos

jamescarppe commented 5 months ago

I note you're using Compose v2.26.1 whereas with Portainer 2.19.5 we ship with v2.20.2 of Compose. I can also see a mention of a fix around the required engine version for the start_interval option in the Compose v2.24.1 release notes so perhaps this was fixed in between the version that Portainer 2.19.5 ships with and the version you're running locally.

Our STS release, Portainer 2.20.2, ships with a newer version of Compose (v2.26.1 in fact) - would it be possible for you to update to 2.20.2 and see if the problem persists? Take a backup before doing so of course!

tamas-boczan commented 5 months ago

It works! Thank you for the great instructions.

I didn't consider that Portainer might ship with its own Compose but it makes total sense. Upgrading to 2.20.2 makes start_interval work as intended.

jamescarppe commented 5 months ago

Thanks for following up, and glad this fixed it! We include the Compose binary with the release so that we can provide Compose functionality within Portainer without relying on the host to have it installed, and also to ensure we're working with a version of Compose that we've tested with. As we release new versions of Portainer we bump the version of the included binaries, so our next LTS release (2.21) will include this too.