Adding Another Plugin To Rabbit Management Docker Image

You are using RabbitMQ management plugin ( rabbitmq:3.8.27-management) and you are getting the following error enabling rabbitmq_delayed_message_exchange

{:plugins_not_found, [:rabbitmq_delayed_message_exchange]}

Command to enable rabbitmq_delayed_message_exchange

rabbitmq-plugins enable rabbitmq_delayed_message_exchange

Perquisites

Create folder structure

Dockerfile

FROM rabbitmq:3.8.27-management

RUN apt-get -o Acquire::Check-Date=false update && apt-get install -y curl

RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/3.8.17/rabbitmq_delayed_message_exchange-3.8.17.8f537ac.ez > $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.8.17.ez

RUN chown rabbitmq:rabbitmq $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.8.17.ez

#RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange

enabled_plugins

[rabbitmq_delayed_message_exchange,rabbitmq_management,rabbitmq_prometheus].

definitions.json

{
   "users": [
    {
      "name": "admin",
      "password": "admin",
      "tags": "administrator"
    }
  ],
  "vhosts": [
    {
      "name": "/"
    }
  ],
  "policies": [
    {
      "vhost": "/",
      "name": "ha",
      "pattern": "",
      "apply-to": "all",
      "definition": {
        "ha-mode": "all",
        "ha-sync-batch-size": 256,
        "ha-sync-mode": "automatic"
      },
      "priority": 0
    }
  ],
  "permissions": [
    {
      "user": "admin",
      "vhost": "/",
      "configure": ".*",
      "write": ".*",
      "read": ".*"
    }
  ],
  "queues": [
    {
      "name": "job-import.triggered.queue",
      "vhost": "/",
      "durable": true,
      "auto_delete": false,
      "arguments": {}
    }
  ],
  "exchanges": [
    {
      "name": "lob-proj-dx",
      "vhost": "/",
      "type": "direct",
      "durable": true,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    }
  ],
  "bindings": [
    {
      "source": "lob-proj-dx",
      "vhost": "/",
      "destination": "job-import.triggered.queue",
      "destination_type": "queue",
      "routing_key": "job-import.event.triggered",
      "arguments": {}
    }
  ]
}

rabbitmq.conf

auth_mechanisms.1 = PLAIN
auth_mechanisms.2 = AMQPLAIN
loopback_users.guest = false
listeners.tcp.default = 5672
#default_pass = admin
#default_user = admin
hipe_compile = false
#management.listener.port = 15672
#management.listener.ssl = false
management.tcp.port = 15672
management.load_definitions = /etc/rabbitmq/definitions.json
#default_pass = admin
#default_user = admin

Build Custom Docker image

docker build -t rabbitmq:3.8.27-md .
docker image ls

Run the custom Docker Image

docker run --restart=always -d -p 5672:5672 -p 15672:15672 --mount type=bind,source=E:\docker\rabbit\data,target=/var/lib/rabbitmq/ --mount type=bind,source=E:\docker\rabbit\etc,target=/etc/rabbitmq/ --name rabbitmq --hostname my-rabbit rabbitmq:3.8.27-md

Validate the plugin enabled

 docker exec -it 9b0bffed911e bash

Start Options

Directly Running

docker run -d --hostname my-rabbit -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:3.8.27-management

docker run -d --hostname my-rabbit -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:3.8.27-md

 rabbitmq-plugins enable rabbitmq_delayed_message_exchange

Docker Compose

version: "3.8"

services:
  rabbitmq:
    build: .
    #image: rabbitmq:3.7.28-management
    #container_name: rabbitmq
    volumes:
        - ./etc/:/etc/rabbitmq/
        - ./data/:/var/lib/rabbitmq/
        - ./logs/:/var/log/rabbitmq/
    environment:
        RABBITMQ_ERLANG_COOKIE: ${RABBITMQ_ERLANG_COOKIE:-secret_cookie}
        RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER:-admin}
        RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS:-admin}
    ports:
        - 5672:5672    #amqp
        - 15672:15672  #http
        - 15692:15692  #prometheus

Either

docker-compose up

Or

docker swarm init
docker stack deploy --compose-file docker-compose.yaml rabbit-delay
docker stack services rabbit-delay
docker stack rm rabbit-delay

References

Install WSL 2 On Windows 10 Using PowerShell Command Line

Enable WSL 2

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enable ‘Virtual Machine Platform’ 

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Set WSL 2 as default

wsl --set-default-version 2

Install a Linux distro

Choose your distro. Simply use one of these URLs:

  • Debian: https://aka.ms/wsl-debian-gnulinux
  • Ubuntu 18.04: https://aka.ms/wsl-ubuntu-1804
  • Ubuntu 16.04: https://aka.ms/wsl-ubuntu-1604
  • Ubuntu 20.04: https://aka.ms/wslubuntu2004
  • openSUSE: https://aka.ms/wsl-opensuse-42
  • SLES: https://aka.ms/wsl-sles-12
  • Kali: https://aka.ms/wsl-kali-linux
# Go to a folder where you would like to download the distro
cd <somefolder>

# Download Ubuntu 20.04
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing

# install downloaded *.appx file
Add-AppxPackage .\Ubuntu.appx

Either execute in command prompt

PS E:\distro\ubunu> ubuntu2004.exe

Or open from widows search

wsl --list --verbos
 
NAME                   STATE           VERSION
Ubuntu-20.04           Running         1
wsl --list --all

Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)

Convert Ubuntu on WSL 1 to WSL 2

wsl --set-version Ubuntu-20.04 2

Open wsl

Restart WSL

Restart-Service LxssManager

or

wsl --terminate [YourDistroName]
wsl --shutdown

Work in VSCode

Open Remote window

server being installed

If you get the following error

The user has not been granted the requested logon type at this computer

Then execute the following

Restart-Service vmcompute

References

Windows 10 Location For Docker Volumes And Container Logs

In Linux, Container Logs can be found in

/var/lib/docker/containers/container-id/container-id-json.log

If your docker info shows the Root Dir as C:\ProgramData\docker then the logs can be found in

C:\ProgramData\docker\containers\[container_ID]\[container_ID]-json.log

The following is for Specific versions

Windows 10 + WSL 2 (Ubuntu 20.04), Docker version 20.10.2, build 2291f61

Logging Driver

C:\Users\reach>docker info --format '{{.LoggingDriver}}'
'json-file'

Docker Inspect LogPath

C:\Users\reach>docker inspect --format='{{.LogPath}}' bb69ae7df957
'/var/lib/docker/containers/bb69ae7df957c5f8c8b6d63372aa9cf9b94fa6ef0e44ccecbccb6d190baadb51/bb69ae7df957c5f8c8b6d63372aa9cf9b94fa6ef0e44ccecbccb6d190baadb51-json.log'

All the docker artifacts are stored in the following location

\\wsl$\docker-desktop-data\version-pack-data\community\docker

As can be seen here, lets call it as DOCKER_ARTIFACTS

Logs

Container logs can be found in the following location

DOCKER_ARTIFACTS\containers\[Your_container_ID]\[Your_container_ID]-json.log

Volumes

Data volumes can be found in

DOCKER_ARTIFACTS\volumes\[VOLUME_ID]\_data