bin
bin

Reputation: 41

use rabbitmqadmin in docker

================Dockerfile1=================

FROM rabbitmq:3-management
MAINTAINER 123 "[email protected]"
RUN apt-get update
ENV REFERSHED_AT 2015-07-20
RUN apt-get install -y python
ADD rabbitmqadmin /usr/local/bin/rabbitmqadmin
RUN chmod 755 /usr/local/bin/rabbitmqadmin
RUN service rabbitmq-server start && /usr/local/bin/rabbitmqadmin declare queue name=my-new-queue durable=true && service rabbitmq-server stop

RUN rabbitmq-plugins enable --offline rabbitmq_management
EXPOSE 15672
CMD rabbitmq-server

==============Dockerfile2===================

FROM rabbitmq:3-management
MAINTAINER 123 "[email protected]"
RUN apt-get update
ENV REFERSHED_AT 2015-07-20
RUN apt-get install -y python
ADD rabbitmqadmin /usr/local/bin/rabbitmqadmin
RUN chmod 755 /usr/local/bin/rabbitmqadmin
RUN rabbitmq-plugins enable --offline rabbitmq_management
EXPOSE 15672
CMD service rabbitmq-server start && /usr/local/bin/rabbitmqadmin declare queue name=my-new-queue durable=true && service rabbitmq-server stop && rabbitmq-server

The queue didn't declared when I use Dockerfile1, but Dockerfile2 works.What's the difference between Dockerfile1 and Dockerfile2?

Upvotes: 4

Views: 8596

Answers (1)

pl_rock
pl_rock

Reputation: 15792

yes , there is difference in Dockerfile1 and Dockerfile2 . you are exposing port 15672 before queue creation in dockerfile2 and exposing after queue command in dockerfile1. Actually Rabbitmqadmin use HTTP API to create queue , exchange etc. if you apply command

curl -u guest:guest -XGET http://localhost:15672/api/queues

you will get list of all queues if you apply command :

curl -i -u guest:guest -H "content-type:application/json" \  
-XPUT -d'{"type":"direct","durable":true}' \
 http://localhost:15672/api/exchanges/%2f/my-new-exchange

it will create new exchange my-new-exchange. without exposing port how will you able to create queue ? . for more info you can go through manual of rabbitmq. http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html

Upvotes: 6

Related Questions