4

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

FROM rabbitmq:3-management
MAINTAINER 123 "qyb1234@everbridge.com"
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 "qyb1234@gmail.com"
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

使用 Dockerfile1 时队列没有声明,但是 Dockerfile2 有效。Dockerfile1 和 Dockerfile2 有什么区别?

4

1 回答 1

6

是的, Dockerfile1 和 Dockerfile2 有区别。您在 dockerfile2 中创建队列之前公开端口 15672,并在 dockerfile1 中的队列命令之后公开。实际上 Rabbitmqadmin 使用 HTTP API 来创建队列,交换等,如果你应用命令

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

如果您应用命令,您将获得所有队列的列表:

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

它将创建新的交换 my-new-exchange。如果不暴露端口,您将如何创建队列?. 有关更多信息,您可以阅读 rabbitmq 手册。 http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html

于 2015-07-21T10:16:30.640 回答