rabbitmq dockerfile

2020-08-10 16:08:53

基於上一篇文章rabbitmq的安裝教學的dockerfile。

dockerfile:

# Base images 基礎映象
FROM centos:centos7
#MAINTAINER 維護者資訊
MAINTAINER tangjianghua
#工作路徑
WORKDIR /var/lib/rabbitmq
#安裝sudo命令單獨做一層
RUN yum install -y sudo
#設定系統編碼
ENV LC_ALL=en_US.UTF-8


#匯入packagecloud pgpkey
RUN rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey && \
#匯入packagecloud erlang倉庫
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash && \
#安裝erlang
yum install -y erlang-22.3.4.5-1.el7.x86_64



#匯入packagecloud rabbitmq-server倉庫
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash && \
#匯入rabbitmq 簽名key
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc && \
#安裝rabbitmq-server 啓動管理外掛
yum install -y rabbitmq-server-3.8.6-1.el7.noarch && rabbitmq-plugins enable rabbitmq_management 
#至此rabbitmq-server安裝完成,下一層做啓動

#暴露amqp埠和管理平臺埠
EXPOSE 5672 15672

#啓動命令
ENTRYPOINT ["rabbitmq-server"]
#設定啓動預設參數,run時指定命令會被覆蓋。
#CMD ["-dit -p 5672:5672 -p 15672:15672 --name 'rabbitmq' -h 'rabbitmq'"]

進入系統新增使用者:

#新增admin使用者
rabbitmqctl add_user 'admin' 'admin'
#授予虛擬機器「/」許可權
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" 
#授予管理平臺登陸許可權
rabbitmqctl set_user_tags admin administrator 


#一起執行
rabbitmqctl add_user 'admin' 'admin' && rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" && rabbitmqctl set_user_tags admin administrator