Score:0

Is it possible to not buffer docker compose output when a health check is used?

vn flag

Re-introduction of health checks with depends_on in docker compose is amazing. Seriously was tired of writing health checks into every downstream container, especially things like a database initialization container.

That said, it seems as soon as I enable a health check/depends on, all output from those containers is buffered until the health check succeeds. Worse - if the container fails to start for some reason, the output is swallowed altogether, and you have to poke around with docker logs to get the output.

So if I have a docker compose file something like:

  mysql:
    image: mysql:8.0
    ...
    healthcheck:
      test: [ "CMD", "mysql", "-u", "username", "--password=password", "-e", "show databases;" ]
      interval: 10s
      timeout: 2s
      retries: 8640
      start_period: 20s
  ...

  health-check-check:
    image: centos:8
    depends_on:
      mysql:
        condition: service_healthy
    command: [ "-c", "echo \"mysql up\"" ]
    entrypoint: "bash"

Is there a way to get the mysql and health-check-check container output to compose stdout

  • a) before the health checks are complete (i.e. unbuffered)
  • b) regardless of health check success/failure
DrTeeth avatar
vn flag
Bonus points for printing the output of the health checks to stdout while we're at it...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.