1. 拉取鏡像
docker pull rabbitmq:management
這里rabbitmq后面帶了management參數(shù)顷歌,說明是帶web管理頁面的
2. 運(yùn)行
docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5672:5672 --restart=always rabbitmq:management
一般docker啟動容器是不需要指定hostname的,不過在dockerhub上是這么解釋的
One of the important things to note about RabbitMQ is that it stores data based on what it calls the "Node Name", which defaults to the hostname. What this means for usage in Docker is that we should specify -h/--hostname explicitly for each daemon so that we don't get a random hostname and can keep track of our data:
3.在web上訪問
如果是本地幔睬,直接訪問 localhost:15672眯漩, 默認(rèn)賬號密碼都是是guest。
如果是在服務(wù)器上麻顶, --hostname 后面應(yīng)該接上你的域名或者ip地址赦抖。
如果需要指定賬號密碼,可以加上-e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password
4.安裝插件
先在community-plugins中找到需要安裝的插件辅肾,下載并解壓zip队萤,得到一個.ez文件。
然后在當(dāng)前目錄下宛瞄,把文件復(fù)制進(jìn)rabbitmq在docker中的plugins目錄:
docker cp rabbitmq_delayed_message_exchange-20171201-3.7.x.ez rabbit:/plugins
再進(jìn)入rabbitmq:
docker exec -it rabbit bash
啟用插件:
rabbitmq-plugins enable rabbitmq_delayed_message_exchange