To create a docker-compose.yml
file for ActiveMQ Artemis (latest) with a few basic functionality to instantly have an EMS broker follow the instructions below.
- Use the
apache/activemq-artemis
Docker image. - Enable persistence (default is
true
, but we can reinforce it). - Mount a volume to store the broker's data (especially the
/var/lib/artemis
directory).
Contents of the docker-compose.yml
file:
services:
artemis:
image: apache/activemq-artemis:latest
container_name: artemis
environment:
- ARTEMIS_USERNAME=admin
- ARTEMIS_PASSWORD=admin
- ARTEMIS_NO_AUTO_CREATE=false
ports:
- "61616:61616" # Core messaging (TCP)
- "8161:8161" # Web console
volumes:
- artemis-data:/var/lib/artemis
restart: unless-stopped
volumes:
artemis-data:
Notes
volumes
: This mounts persistent storage for Artemis at/var/lib/artemis
, which includes journal and bindings directories necessary for message persistence.restart: unless-stopped
: Ensures the container restarts unless you explicitly stop it.ARTEMIS_NO_AUTO_CREATE=false
: Ensures destinations (queues/topics) can be auto-created if not present.- By default, persistence is enabled in Artemis (
persistence-enabled=true
inbroker.xml
). This setup assumes default configuration is used. - To confirm or customize persistence settings like journal type or data directory, you’d need to mount a custom
broker.xml
. If you want that, let me know—I can help create it.
Starting the service
Run the following:
docker compose up -d
To verify persistence is working:
- Send messages to a queue.
- Restart the container with
docker compose restart
. - Confirm that the messages are still there via the web console (
http://localhost:8161
).