创建Docker私有网络
docker network create rabbitmqnet
docker run -d --name=rabbitmq1 -p 5673:5672 -p 15673:15672 -e RABBITMQ_NODENAME=rabbitmq1 -e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' -h rabbitmq1 --net=rabbitmqnet rabbitmq:3.6.10-management
docker run -d --name=rabbitmq2 -p 5674:5672 -p 15674:15672 -e RABBITMQ_NODENAME=rabbitmq2 -e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' -h rabbitmq2 --net=rabbitmqnet rabbitmq:3.6.10-management
docker run -d --name=rabbitmq3 -p 5675:5672 -p 15675:15672 -e RABBITMQ_NODENAME=rabbitmq3 -e RABBITMQ_ERLANG_COOKIE='YZSDHWMFSMKEMBDHSGGZ' -h rabbitmq3 --net=rabbitmqnet rabbitmq:3.6.10-management
docker exec rabbitmq2 bash -c "rabbitmqctl stop_app &&
rabbitmqctl reset &&
rabbitmqctl join_cluster --ram rabbitmq1@rabbitmq1 &&
rabbitmqctl start_app"
docker exec rabbitmq3 bash -c "rabbitmqctl stop_app &&
rabbitmqctl reset &&
rabbitmqctl join_cluster --ram rabbitmq1@rabbitmq1 &&
rabbitmqctl start_app"
--ram 指定了节点类型,目前一个磁盘节点两个内存节点
主要参考
http://www.echojb.com/erlang/2016/09/26/216623.html
http://www.dockone.io/article/829