-2

I try to exec rabbitmq on container.

Making Dockerfile

FROM rabbitmq:3.12.0-management

RUN apt-get update
RUN apt-get install -y curl

then,build the docker image.

$docker build -t rabbit -f Dockerfile .

exec docker container

$docker run -it rabbit 

2023-06-14 12:38:32.952197+00:00 [info] <0.539.0> Started message store of type persistent for vhost '/'
2023-06-14 12:38:32.952307+00:00 [info] <0.539.0> Recovering 0 queues of type rabbit_classic_queue took 4ms
2023-06-14 12:38:32.952332+00:00 [info] <0.539.0> Recovering 0 queues of type rabbit_quorum_queue took 0ms
2023-06-14 12:38:32.952351+00:00 [info] <0.539.0> Recovering 0 queues of type rabbit_stream_queue took 0ms
2023-06-14 12:38:32.953670+00:00 [info] <0.230.0> Created user 'guest'
2023-06-14 12:38:32.954343+00:00 [info] <0.230.0> Successfully set user tags for user 'guest' to [administrator]
2023-06-14 12:38:32.954963+00:00 [info] <0.230.0> Successfully set permissions for user 'guest' in virtual host '/' to '.*', '.*', '.*'
2023-06-14 12:38:32.954994+00:00 [info] <0.230.0> Running boot step rabbit_observer_cli defined by app rabbit
2023-06-14 12:38:32.955024+00:00 [info] <0.230.0> Running boot step rabbit_looking_glass defined by app rabbit
2023-06-14 12:38:32.955071+00:00 [info] <0.230.0> Running boot step rabbit_core_metrics_gc defined by app rabbit
2023-06-14 12:38:32.955173+00:00 [info] <0.230.0> Running boot step background_gc defined by app rabbit
2023-06-14 12:38:32.955312+00:00 [info] <0.230.0> Running boot step routing_ready defined by app rabbit
2023-06-14 12:38:32.955340+00:00 [info] <0.230.0> Running boot step pre_flight defined by app rabbit
2023-06-14 12:38:32.955358+00:00 [info] <0.230.0> Running boot step notify_cluster defined by app rabbit
2023-06-14 12:38:32.955377+00:00 [info] <0.230.0> Running boot step networking defined by app rabbit
2023-06-14 12:38:32.955420+00:00 [info] <0.230.0> Running boot step definition_import_worker_pool defined by app rabbit
2023-06-14 12:38:32.955448+00:00 [info] <0.282.0> Starting worker pool 'definition_import_pool' with 4 processes in it
2023-06-14 12:38:32.955648+00:00 [info] <0.230.0> Running boot step cluster_name defined by app rabbit
2023-06-14 12:38:32.955704+00:00 [info] <0.230.0> Initialising internal cluster ID to 'rabbitmq-cluster-id-ENMQ3NsbofEiQN-EkQgqGQ'
2023-06-14 12:38:32.956490+00:00 [info] <0.230.0> Running boot step direct_client defined by app rabbit
2023-06-14 12:38:32.956555+00:00 [info] <0.230.0> Running boot step rabbit_maintenance_mode_state defined by app rabbit
2023-06-14 12:38:32.956577+00:00 [info] <0.230.0> Creating table rabbit_node_maintenance_states for maintenance mode status
2023-06-14 12:38:32.958292+00:00 [info] <0.230.0> Running boot step rabbit_management_load_definitions defined by app rabbitmq_management
2023-06-14 12:38:32.958362+00:00 [info] <0.591.0> Resetting node maintenance status
2023-06-14 12:38:32.965039+00:00 [info] <0.650.0> Management plugin: HTTP (non-TLS) listener started on port 15672
2023-06-14 12:38:32.965113+00:00 [info] <0.678.0> Statistics database started.
2023-06-14 12:38:32.965158+00:00 [info] <0.677.0> Starting worker pool 'management_worker_pool' with 3 processes in it
2023-06-14 12:38:32.969545+00:00 [info] <0.692.0> Prometheus metrics: HTTP (non-TLS) listener started on port 15692
2023-06-14 12:38:32.969623+00:00 [info] <0.591.0> Ready to start client connection listeners
2023-06-14 12:38:32.970623+00:00 [info] <0.736.0> started TCP listener on [::]:5672
 completed with 4 plugins.
2023-06-14 12:38:33.050716+00:00 [info] <0.591.0> Server startup complete; 4 plugins started.
2023-06-14 12:38:33.050716+00:00 [info] <0.591.0>  * rabbitmq_prometheus
2023-06-14 12:38:33.050716+00:00 [info] <0.591.0>  * rabbitmq_management
2023-06-14 12:38:33.050716+00:00 [info] <0.591.0>  * rabbitmq_web_dispatch
2023-06-14 12:38:33.050716+00:00 [info] <0.591.0>  * rabbitmq_management_agent

It looks like server works correctly the port 15672 or 15692 or 5672

And check if docker container also works.

$docker container ps -a
CONTAINER ID   IMAGE     COMMAND                   CREATED              STATUS              PORTS                                                                  NAMES
f05906c9595a   rabbit    "docker-entrypoint.s…"   About a minute ago   Up About a minute   4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 15691-15692/tcp, 25672/tcp   romantic_pascal

Then I try to access,however not work.

% curl localhost:5671
curl: (7) Failed to connect to localhost port 5671 after 3 ms: Couldn't connect to server
% curl localhost:15671
curl: (7) Failed to connect to localhost port 15671 after 2 ms: Couldn't connect to server
% curl localhost:15672
curl: (7) Failed to connect to localhost port 15672 after 2 ms: Couldn't connect to server

How can I access to the dashboard?

whitebear
  • 11,200
  • 24
  • 114
  • 237
  • [Connecting to Postgresql in a docker container from outside](https://stackoverflow.com/questions/37694987/connecting-to-postgresql-in-a-docker-container-from-outside) is a very similar case, but for a different port number; the second `docker run -p` port number needs to be the RabbitMQ broker port 5672. – David Maze Jun 14 '23 at 15:48

1 Answers1

1

Run the container as:

docker run -it -p 5672:5672 -p 15672:15672 rabbit

and then browse it with http://localhost:15672 or curl http://localhost:15672

Alez
  • 1,913
  • 3
  • 18
  • 22