===== 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之间的区别是什么?
答案 0 :(得分:4)
是的,Dockerfile1和Dockerfile2存在差异。您在dockerfile2中创建队列之前暴露端口15672并在dockerfile1中的queue命令之后公开。 实际上,如果你应用命令
,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
它将创建新的交换我的新交换。 没有暴露端口你将如何创建队列? 。 有关更多信息,您可以通过rabbitmq手册。 http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html