Search code examples
dockermacosdocker-composeactivemq-artemis

Failed to deploy ActiveMQ Artemis in Docker container on Mac M1


I'm trying to run ActiveMQ Artemis on Mac M1.

docker run --detach --name mycontainer -p 61616:61616 -p 8161:8161 --rm apache/activemq-artemis:latest-alpine
2024-02-09 20:30:14 CREATE_ARGUMENTS=--user artemis --password artemis --silent --require-login --http-host 0.0.0.0 --relax-jolokia
 Cannot initialize queue:Function not implemented

 Usage: artemis help [<args>...]
 use 'help <command>' for more information
     [<args>...]

If I will use

EXTRA_ARGS: "--nio --host 0.0.0.0 --http-host 0.0.0.0 --relax-jolokia"

[Too many errors, abort] 2024-02-09 20:44:26 qemu: uncaught target signal 11 (Segmentation fault) - core dumped

I have used:

version: "3.8"
services:
  activemq-artemis:
    container_name: artemis_simple
    image: apache/activemq-artemis:latest-alpine
    environment:
      ARTEMIS_USER: "artemis"
      ARTEMIS_PASSWORD: "artemis"
      EXTRA_ARGS: "--nio"
    ports:
      - "8161:8161"
      - "61616:61616"
   restart: unless-stopped
    networks:
      - artemis

networks:
  artemis:
    driver: bridge

It started at first, there were a few errors, but however I can't connect to the web console

Auto tuning journal ...
2024-02-09 20:34:50 done! Your system can make 8.62 writes per millisecond, your journal-buffer-timeout will be 115999
2024-02-09 20:34:50 
2024-02-09 20:34:50 You can now start the broker by executing:  
2024-02-09 20:34:50 
2024-02-09 20:34:50    "/var/lib/artemis-instance/bin/artemis" run
2024-02-09 20:34:50 
2024-02-09 20:34:50 Or you can run the broker in the background using:
2024-02-09 20:34:50 
2024-02-09 20:34:50    "/var/lib/artemis-instance/bin/artemis-service" start
............

[Too many errors, abort]
2024-02-09 20:44:26 qemu: uncaught target signal 11 (Segmentation fault) - core dumped

Who has any idea how you can deploy ActiveMQ Artemis on a Mac M1 in Docker container?


Solution

  • The error Cannot initialize queue:Function not implemented is caused by the fact that AIO isn't working in your environment as explained here. Therefore, you need to use NIO instead of AIO.

    However, if you only specify "--nio" in your EXTRA_ARGS that will overwrite the default EXTRA_ARGS (i.e. --http-host 0.0.0.0 --relax-jolokia) and prevent you from accessing the web console.

    I believe the [Too many errors, abort] error is due to a platform mismatch. You need to ensure you're using the arm64 image variant.

    Putting it all together now...

    This should work to use NIO, bind the embedded web server to 0.0.0.0 so you can access the web console from outside the container, and ensure you're using the right platform:

    docker run --platform linux/arm64 -e ARTEMIS_USER=artemis -e ARTEMIS_PASSWORD=artemis -e EXTRA_ARGS="--nio --host 0.0.0.0 --http-host 0.0.0.0 --relax-jolokia" --name mycontainer -it -p 61616:61616 -p 8161:8161 apache/activemq-artemis:latest-alpine
    

    This should also work with docker-compose:

    version: "3.8" 
    services: 
      activemq-artemis: 
        container_name: artemis_simple 
        image: apache/activemq-artemis:latest-alpine 
        environment: 
          ARTEMIS_USER: "artemis" 
          ARTEMIS_PASSWORD: "artemis" 
          EXTRA_ARGS: "--nio --host 0.0.0.0 --http-host 0.0.0.0 --relax-jolokia" 
        ports: 
          - "8161:8161" 
          - "61616:61616" 
        networks: 
          - artemis
        platform:
          "linux/arm64"
    
    networks: 
      artemis: 
        driver: bridge