Skip to content

Commit 461276d

Browse files
committed
add docker-compose healthcheck
1 parent 5c52abe commit 461276d

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

docker-compose.yaml

+33-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ services:
99
environment:
1010
ZOOKEEPER_CLIENT_PORT: 2181
1111
ZOOKEEPER_TICK_TIME: 2000
12+
healthcheck:
13+
test: nc -z localhost 2181 || exit -1
14+
interval: 30s
15+
timeout: 5s
16+
retries: 5
17+
start_period: 20s
1218

1319
broker:
1420
image: confluentinc/cp-enterprise-kafka:5.5.0
1521
hostname: broker
1622
container_name: broker
1723
depends_on:
18-
- zookeeper
24+
zookeeper:
25+
condition: service_healthy
1926
ports:
2027
- "29092:29092"
2128
environment:
@@ -27,27 +34,42 @@ services:
2734
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
2835
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
2936
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
37+
healthcheck:
38+
test: kafka-topics --bootstrap-server broker:9092 --list
39+
interval: 30s
40+
timeout: 20s
41+
retries: 3
42+
start_period: 20s
3043

3144
schema-registry:
3245
image: confluentinc/cp-schema-registry:5.5.0
3346
hostname: schema-registry
3447
container_name: schema-registry
3548
depends_on:
36-
- zookeeper
37-
- broker
49+
zookeeper:
50+
condition: service_healthy
51+
broker:
52+
condition: service_healthy
3853
ports:
3954
- "8081:8081"
4055
environment:
4156
SCHEMA_REGISTRY_HOST_NAME: schema-registry
4257
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
58+
healthcheck:
59+
test: curl --output /dev/null --silent --head --fail http://schema-registry:8081/subjects
60+
interval: 30s
61+
timeout: 10s
62+
retries: 3
4363

4464
ksqldb-server:
4565
image: confluentinc/ksqldb-server:0.10.1
4666
hostname: ksqldb-server
4767
container_name: ksqldb-server
4868
depends_on:
49-
- broker
50-
- schema-registry
69+
broker:
70+
condition: service_healthy
71+
schema-registry:
72+
condition: service_healthy
5173
ports:
5274
- "8088:8088"
5375
volumes:
@@ -72,6 +94,12 @@ services:
7294
KSQL_CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
7395
KSQL_CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
7496
KSQL_CONNECT_PLUGIN_PATH: "/usr/share/kafka/plugins"
97+
healthcheck:
98+
test: nc -z localhost 8088 || exit -1
99+
interval: 10s
100+
timeout: 5s
101+
retries: 3
102+
start_period: 20s
75103

76104
ksqldb-cli:
77105
image: confluentinc/ksqldb-cli:0.10.1

0 commit comments

Comments
 (0)