Recently, I needed to work with ActiveMQ. As a docker fan, I couldn’t find the latest version (5.17.2) docker image available. Thus, I decided to build one.
It turned out that building a docker image for ActiveMQ is quite simple. For example, here is the Dockerfile for ActiveMQ version 5.17.2 on JRE 19, alpine:
FROM eclipse-temurin:19-jre-alpine as build ENV ACTIVEMQ_VERSION 5.17.2 ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION ENV ACTIVEMQ_TCP=61616 ACTIVEMQ_AMQP=5672 ACTIVEMQ_STOMP=61613 ACTIVEMQ_MQTT=1883 ACTIVEMQ_WS=61614 ACTIVEMQ_UI=8161 ENV SHA512_VAL=7c6ee4c1a9f58ccaa374d8528255d55c181c3402855fe06202bb30f722bdbd69a2cebaf0eded67324f94b4158b6d8d97b621d8730d92676e51b982ed4fc8a7b0 ENV USER_ID=65535 ENV GROUP_ID=65535 ENV USER_NAME=activemq ENV GROUP_NAME=activemq RUN apk add curl RUN curl "https://archive.apache.org/dist/activemq/$ACTIVEMQ_VERSION/$ACTIVEMQ-bin.tar.gz" -o $ACTIVEMQ-bin.tar.gz # Validate checksum RUN if [ "$SHA512_VAL" != "$(sha512sum $ACTIVEMQ-bin.tar.gz | awk '{print($1)}')" ];\ then \ echo "sha512 values doesn't match! exiting." && \ exit 1; \ fi; RUN tar -xzf $ACTIVEMQ-bin.tar.gz -C /opt && \ addgroup -g $GROUP_ID $GROUP_NAME && \ adduser --shell /sbin/nologin --disabled-password \ --no-create-home --uid $USER_ID --ingroup $GROUP_NAME $USER_NAME && \ chown -R $USER_NAME:$GROUP_NAME /opt/$ACTIVEMQ && \ sed -i 's/127.0.0.1/0.0.0.0/g' /opt/$ACTIVEMQ/conf/jetty.xml USER activemq WORKDIR /opt/$ACTIVEMQ EXPOSE $ACTIVEMQ_TCP $ACTIVEMQ_AMQP $ACTIVEMQ_STOMP $ACTIVEMQ_MQTT $ACTIVEMQ_WS $ACTIVEMQ_UI CMD ["/bin/sh", "-c", "./bin/activemq console"]
Build ActiveMQ docker image for a different version
You can reuse the Dockerfile above to build other images on different JRE versions. However, there are some things you need to pay attention to:
- Replace the correct ACTIVEMQ_VERSION (in the file above, it’s 5.17.2)
- Replace the correct SHA512_VAL version. You can get this value on the download page.
That’s all you need to build a new docker image for ActiveMQ.
Running ActiveMQ container
Running an ActiveMQ container is quite simple. For example, this command runs ActiveMQ 5.17.2
docker run -p 61616:61616 -p 8161:8161 codingpuss/activemq:5.17.2-jre-19-alpine
In the example above, I mapped port 8186 for web admin and port 61616 for TCP. If you need other protocols, map them accordingly. All the ports for each protocol are available at line 5 of the Dockerfile above.
For more information and all tags, you can checkout this Docker hub page
I build softwares that solve problems. I also love writing/documenting things I learn/want to learn.