English 中文(简体)
make docker-compose block until healthy without `depends_on`
原标题:

I am working with a team that uses docker-compose to start a set of helper services, but does not use docker when the code is being developed.

Here, docker-compose is just a convenient way to run the helper services while we develop the main server code.

We have a lot of custom code that tries to detect if the helper services are healthy. I would like to use the healthcheck feature of docker-compose.

However, docker-compose does not block unless you define some service as depends_on: ... condition: service healthy. In my case I ve done this stupid thing; I ve simply run hello-world and made it block on the other services being healthy.

  helper1:
    ...
    healthcheck:
      test: ["CMD", "curl", "-f", "http://helper1:1234/ready"]
      interval: 10s
      timeout: 5s
      retries: 5
  helper2:
    ...
    healthcheck:
      test: ["CMD", "curl", "-f", "http://helper2:5678/health"]
      interval: 10s
      timeout: 5s
      retries: 5
  hello-world:
    image: docker.io/library/hello-world
    depends_on:
      helper1:
        condition: service_healthy
      helper2:
        condition: service_healthy

Having a dummy service seems inelegant. Is there another way to make my docker-compose command block until everything is healthy?

问题回答

暂无回答




相关问题
Unable to connect to docker container inside windows server

As title. I am developing a system with many docker images with ASP.Net MVC core projects. I am publishing these docker images into a docker engine installed on Windows Server OS, and I found that I ...

Only can see postgreSQL as an admin

After installed Wsl and Docker, can t access PSQL and other things. I was studying Docker, and installed the latest version. So far so good, I received an error about the WSL version, saw some ...

make docker-compose block until healthy without `depends_on`

I am working with a team that uses docker-compose to start a set of helper services, but does not use docker when the code is being developed. Here, docker-compose is just a convenient way to run the ...

change grafana port using docker host network

I am trying to spin up a grafana container in docker, however my setup in docker does not allow ipv4 forwarding and thus I cannot use the default bridge network in docker. All I can use is the host ...

Pip instalation for Python 3.11 in docker

I have Dockerfile to build image for Django project that uses Python 3.11 and runs in poetry environment (see content below). Problem is when I try to donwload get-pip.py file and run it using Python, ...

在 Dockerfile 中运行 composer install

我正在尝试将我的Laravel应用程序进行Docker化。 该应用程序已经构建并在Git中,但我将vendor文件夹添加到了.gitignore中。 我添加了一个Dockerfile,看起来像这样: FROM php:7.1-fpm-alpine RUN apk update ...

热门标签