1,编写rabbitmq的Dockerfile
#次镜像用于rabbitmq
FROM centos:7.2.1511
MAINTAINER zzli
RUN yum install -y wget unzip tar
RUN wget https://github.com/rabbitmq/erlang-rpm/releases/download/v19.3.6.5/erlang-19.3.6.5-1.el7.centos.x86_64.rpm
RUN yum install -y erlang-19.3.6.5-1.el7.centos.x86_64.rpm
RUN yum install -y erlang
RUN rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
RUN yum install -y https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.0/rabbitmq-server-3.7.0-1.el7.noarch.rpm
RUN /usr/sbin/rabbitmq-plugins list <<<'y'
RUN /usr/sbin/rabbitmq-plugins enable --offline rabbitmq_mqtt rabbitmq_stomp rabbitmq_management rabbitmq_management_agent rabbitmq_federation<
<<'y'
ADD rabbitmq.sh /etc/rabbitmq/
RUN chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie \
&& chmod 400 /var/lib/rabbitmq/.erlang.cookie \
&& chmod +x /etc/rabbitmq/rabbitmq.sh
EXPOSE 5672
EXPOSE 15672
EXPOSE 25672
EXPOSE 4369
EXPOSE 9100
EXPOSE 9101
EXPOSE 9102
EXPOSE 9103
EXPOSE 9104
EXPOSE 9105
ENTRYPOINT ["/etc/rabbitmq/rabbitmq.sh"]
提交镜像:
docker build . -t phj/rabbitmq:0.1
2,启动docker
docker run -idt --hostname rabbitmq -p 5672:5672 -p 15672:15672 --name rabbitmq phj/rabbitmq:0.3
3,rabbitmq.sh脚本内容如下:
#!/bin/bash
HOSTNAME=`env hostname`
/usr/sbin/rabbitmq-server &
rabbitmqctl wait /var/lib/rabbitmq/mnesia/rabbit\@$HOSTNAME.pid
rabbitmqctl delete_user guest
rabbitmqctl add_user admin puhuijia
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
tail -f /var/log/rabbitmq/rabbit\@$HOSTNAME.log
网友评论