ActiveMQ Artemis is used for asynchronous messaging.

Building an ActiveMQ Artemis image

To build an ActiveMQ Artemis image


  1. Ceate the following files :
    1. messaging/docker-compose.yml
      version: '2.4'
      
      services:
        messaging:
          image: apache/activemq-artemis:2.41.0-alpine
          container_name: messaging
          mem_limit: 2g
          ports:
            - "61616:61616"  # Core Messaging Port
            - "8161:8161"    # Management Console (Artemis Web UI)
          environment:
            - ARTEMIS_USER=artemis
            - ARTEMIS_PASSWORD=artemis
            # EXTRA_ARGS allows the web console to be accessed from outside the container
            - EXTRA_ARGS=--http-host 0.0.0.0 --relax-jolokia
              # volumes:
            # Persists all configurations and message queues to your host
            # - ./data/messaging:/var/lib/artemis-instance
          healthcheck:
            test: ["CMD", "nc", "-z", "localhost", "61616"]
            interval: 10s
            timeout: 5s
            retries: 5
            start_period: 30s
          networks:
            - twc-net
      
      networks:
        twc-net:
          external: true
      SHELL
    2. messaging/dockerfile
      # Use the specific official 2.41.0 alpine image
      FROM apache/activemq-artemis:2.41.0-alpine
      
      # These env vars match your WebApp configuration
      ENV ARTEMIS_USER=artemis
      ENV ARTEMIS_PASSWORD=artemis
      
      # Optional: Add extra arguments for the broker
      ENV EXTRA_ARGS="--http-host 0.0.0.0 --relax-jolokia"
      
      # Ensure the container runs as the artemis user for security
      USER artemis
      
      
      SHELL

  2. Build the image by running the following command:
    cd /twc/messaging;
    docker compose build --no-cache
    SHELL
  3. Start the messaging Docker:
    docker compose up -d
    SHELL