我需要等待Clickhouse启动,然后才能启动后端服务器,但是健康检查不起作用。
这是我的docker-compose.yml文件:
version: '3.9'
services:
server:
build: .
depends_on:
clickhouse:
condition: service_healthy
clickhouse:
image: yandex/clickhouse-server
ports:
- '8123:8123'
- '9000:9000'
- '9009:9009'
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8123']
interval: 5s
timeout: 3s
retries: 5然而,当我运行docker-compose up --build时,您可以看到Clickhouse服务器启动,一切都很好,但是健康检查从未通过。该命令以错误:container for service "Clickhouse" is unhealthy先发制人地退出。但是,如果在此期间在我自己的计算机上运行命令curl -f http://localhost:8123 (在停靠容器之外),那么它将返回Ok.。
那么,在开始另一项服务之前,有没有办法等待Clickhouse的健康呢?
发布于 2022-08-11 19:47:46
试着这样做:
..
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8123/?query=SELECT%201 || exit 1
..或
..
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1
..https://stackoverflow.com/questions/73325805
复制相似问题