Skip to content

HealthCmd incorrectly generated/misses CMD-SHELL suffix #160

@rugk

Description

@rugk

STR

I have this docker-compose file:

# based ob https://github.com/orangecoding/fredy/blob/7ebd73c9cf209b57f667cd168f8d18c3e2e1001c/docker-compose.yml
services:
  fredy:
    image: ghcr.io/orangecoding/fredy 
    ports:
      - "9998:9998"
    restart: unless-stopped
    healthcheck:
      # The container will immediately stop when health check fails after retries
      test: ["CMD-SHELL", "curl --fail --silent --show-error --max-time 5 http://localhost:9998/ || exit 1"]
      interval: 120s
      timeout: 10s
      retries: 1
      start_period: 10s
    labels:
      - io.containers.autoupdate=registry

Now through podman this generates:

$ cat ~/.config/containers/systemd/fredy.container 
[Container]
AutoUpdate=registry
HealthCmd='curl --fail --silent --show-error --max-time 5 http://localhost:9998/ || exit 1'
HealthInterval=120s
HealthRetries=1
HealthStartPeriod=10s
HealthTimeout=10s
Image=ghcr.io/orangecoding/fredy
PublishPort=9998:9998

[Service]
Restart=always

[Install]
WantedBy=default.target

What happens

I noticed the container will always be unhealthy though, although manually executing the health check (like curl --fail --silent --show-error --max-time 5 http://localhost:9998/ || exit 1) works.

Docs: https://docs.docker.com/reference/compose-file/services/#healthcheck

What should happen

I found containers/podman#22804 and I guess it's the result of this aka for some reason it misses/removes the CMD-SHELL command.

Also it should remove the ' quoting, this apparently also prevents healthcheck from executing.

Aka, in this case, it should be this:

HealthCmd=CMD-SHELL curl --fail --silent --show-error --max-time 5 http://localhost:9998/ || exit 1

System

$ podlet --version
podlet 0.2.4
$ podman --version
podman version 5.6.0

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