enable mqtt plugin and create user in docker-compose
I need to register a new user on the rabbitmq service after starting docker compose on the tests/docker-compose.yml
. I tried with adding the following commands to the rabbitmq
section in docker-compose.yml
:
command: "/bin/bash -c \"rabbitmq-plugins enable rabbitmq_mqtt\""
command: "/bin/bash -c \"rabbitmqctl add_user test test;rabbitmqctl set_user_tags test administrator;rabbitmqctl set_permissions -p / test '.*' '.*' '.*'\""
Which then exits with the following exception:
> rabbitmq_1 | Error: unable to perform an operation on node 'rabbit@d4b8d0d9d2a3'. Please see diagnostics information and suggestions below.
> rabbitmq_1 |
> rabbitmq_1 | Most common reasons for this are:
> rabbitmq_1 |
> rabbitmq_1 | * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
> rabbitmq_1 | * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
> rabbitmq_1 | * Target node is not running
> rabbitmq_1 |
> rabbitmq_1 | In addition to the diagnostics info below:
> rabbitmq_1 |
> rabbitmq_1 | * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
> rabbitmq_1 | * Consult server logs on node rabbit@d4b8d0d9d2a3
> rabbitmq_1 | * If target node is configured to use long node names, don't forget to use --longnames with CLI tools
> rabbitmq_1 |
> rabbitmq_1 | DIAGNOSTICS
> rabbitmq_1 | ===========
> rabbitmq_1 |
> rabbitmq_1 | attempted to contact: [rabbit@d4b8d0d9d2a3]
> rabbitmq_1 |
> rabbitmq_1 | rabbit@d4b8d0d9d2a3:
> rabbitmq_1 | * connected to epmd (port 4369) on d4b8d0d9d2a3
> rabbitmq_1 | * epmd reports: node 'rabbit' not running at all
> rabbitmq_1 | no other nodes on d4b8d0d9d2a3
> rabbitmq_1 | * suggestion: start the node
> rabbitmq_1 |
> rabbitmq_1 | Current node details:
> rabbitmq_1 | * node name: 'rabbitmqcli-8-rabbit@d4b8d0d9d2a3'
> rabbitmq_1 | * effective user's home directory: /var/lib/rabbitmq
> rabbitmq_1 | * Erlang cookie hash: sikarqNMYurCBljAEwX31Q==
>
The service needs a few seconds to start, thus I would guess rabbitmq wasn't ready for the command
s. @fd Do you know how to sleep
the command before executing?