healthcheck
this is a feature request. docker 1.12 added a HEALTHCHECK command, which would be a useful feature IMO, particularly if deploying activemq into a docker swarm...
I've had a play with trying to run something from a shell which might indicate a working activemq instance (I'm imagining that listing brokers and getting a non-zero response, or putting a message onto a queue and reading it back) - but I haven't had any success yet.
I had limited success using netcat
healthcheck:
test: nc -z localhost 8311 || exit 1
interval: 20s
timeout: 10s
retries: 10
where 8311 is to port to check
However, this seems to trigger
org.apache.activemq.broker.TransportConnection.Transport - Transport failed: java.io.EOFException INFO messages
because the client connection is not closed properly
I have found out cleaner solution, eg. via Dockerfile:
HEALTHCHECK --interval=1s \
--start-period=10s \
CMD ( \
curl \
--silent \
--show-error \
"http://localhost:8161/api/jolokia/exec/org.apache.activemq:type=Broker,brokerName=localhost,service=Health/healthStatus" \
# copy output to fd3 (grep will consume fd1)
| tee /dev/fd/3 \
| grep --silent 'Good' \
# show curl output, from fd3
) 3>&1
Then see health detail via docker inspect <containerName>
...
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2019-10-02T10:56:23.3046307Z",
"End": "2019-10-02T10:56:23.4643366Z",
"ExitCode": 0,
"Output": "{\"request\":{\"mbean\":\"org.apache.activemq:brokerName=localhost,service=Health,type=Broker\",\"type\":\"exec\",\"operation\":\"healthStatus\"},\"value\":\"Good\",\"timestamp\":1570013783,\"status\":200}"
},
...