When adding a HEALTHCHECK directive to the docker image that tries to use discovery mechanism, there is a chicken and egg problem during service discovery.
We are using Spring managed hazelcast instances, so all of our configurations are done at startup. When using a docker healthcheck, the local task is in the starting state when discoverContainersViaCriteria runs. This causes an NPE when SwarmMemberAddressProvider.getBindAddress() is called, because myAddress inside SwarmDiscoveryUtil was never populated.
When adding a HEALTHCHECK directive to the docker image that tries to use discovery mechanism, there is a chicken and egg problem during service discovery.
We are using Spring managed hazelcast instances, so all of our configurations are done at startup. When using a docker healthcheck, the local task is in the
starting
state whendiscoverContainersViaCriteria
runs. This causes an NPE whenSwarmMemberAddressProvider.getBindAddress()
is called, because myAddress insideSwarmDiscoveryUtil
was never populated.The issue is here:
https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/blob/a125c386ca9858d1193b58739088e623b0eb943f/src/main/java/org/bitsofinfo/hazelcast/discovery/docker/swarm/SwarmDiscoveryUtil.java#L389-L396
Here is my fix: c0be5de91f00729a3228d6630873573ed3cb3c0a but I don't know if it will fit in with all of the strategies you are using.