File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ RUN set -eux; \
4343# https://github.com/apache/cassandra/blob/18bcda2d4c2eba7370a0b21f33eed37cb730bbb3/bin/cassandra#L90-L100
4444# https://github.com/apache/cassandra/commit/604c0e87dc67fa65f6904ef9a98a029c9f2f865a
4545 numactl \
46+ # required for docker health-check
47+ netcat \
4648 ; \
4749 rm -rf /var/lib/apt/lists/*; \
4850# https://issues.apache.org/jira/browse/CASSANDRA-15767 ("bin/cassandra" only looks for "libjemalloc.so" or "libjemalloc.so.1" which doesn't match our "libjemalloc.so.2")
@@ -127,4 +129,8 @@ ENTRYPOINT ["docker-entrypoint.sh"]
127129# 9042: CQL
128130# 9160: thrift service
129131EXPOSE 7000 7001 7199 9042 9160
132+
133+ # Check the daemon is listening on CQL/JMX ports
134+ HEALTHCHECK CMD /usr/bin/nc localhost -z 9042 && /usr/bin/nc localhost -z 7199 || exit 1
135+
130136CMD ["cassandra" , "-f" ]
Original file line number Diff line number Diff line change 4848docker network create cassandra-test 2> /dev/null || true
4949
5050CONTAINER_ID=` docker run --rm --name cassandra-test --network cassandra-test -d apache/cassandra-test`
51- CONTAINER_IP=` docker inspect -f ' {{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_ID `
5251
53- until nc -z $CONTAINER_IP 9042
52+ until [ " $( docker container inspect -f ' {{.State.Health.Status}} ' $CONTAINER_ID ) " != " starting " ]
5453do
55- echo " Waiting for cassandra-test container $CONTAINER_ID to start listening on $CONTAINER_IP :9042.. ."
54+ echo " Waiting for cassandra-test container $CONTAINER_ID to start."
5655 sleep 5
5756done
5857
59- echo " cassandra-test container started with id $CONTAINER_ID and ip $CONTAINER_IP "
58+ if [ " $( docker container inspect -f ' {{.State.Health.Status}}' $CONTAINER_ID ) " != " healthy" ]; then
59+ echo " Cassandra test container $CONTAINER_ID started but is unhealty."
60+ exit 1
61+ fi
62+
63+ echo " cassandra-test container started with id $CONTAINER_ID "
6064display_help
You can’t perform that action at this time.
0 commit comments