docker-compose安裝rabbitmq

編寫時間:2020-05-08docker

參考文檔:docker安裝rabbitmq瀏覽器

1. 編寫docker-compose.ymlapp

version: '3' services: rabbitmq: image: rabbitmq:3.8.3-management container_name: rabbitmq restart: always hostname: myRabbitmq ports: - 15672:15672 - 5672:5672 volumes: - ./data:/var/lib/rabbitmq environment: - RABBITMQ_DEFAULT_USER=root - RABBITMQ_DEFAULT_PASS=root

2. 瀏覽器訪問 ip:15672便可,用戶名,密碼輸入root登陸。dom

注意:this

1. application.yml文件中推薦爲docker容器設置hostname,由於rabbitmq默認使用hostname做爲存儲數據的節點名,設置hostname能夠避免生成隨機的節點名,方便追蹤數據。官網原文以下spa

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:rest

2. RABBITMQ_DEFAULT_USER  和  RABBITMQ_DEFAULT_PASS 用來設置超級管理員的帳號和密碼,若是不設置,默認都是 guestcode

3.  docker鏡像使用像這樣 rabbitmq:3.8.3-management  帶有後綴 -management的鏡像,以前使用沒帶這個後綴的鏡像,網頁訪問失敗,以下圖。blog

 

相關文章
相關標籤/搜索