Error(19) 解决docker-compose启动rabbitmq报错RABBITMQ_DEFAULT_PASS is set but deprecated问题_郑清-程序员宅基地

技术标签: 解决启动报错问题  # ②、error大全  rabbitmq  docker-compose  

一、问题

docker-compose启动rabbitmq报错日志如下:

error: RABBITMQ_DEFAULT_PASS is set but deprecated
error: RABBITMQ_DEFAULT_USER is set but deprecated
error: RABBITMQ_DEFAULT_VHOST is set but deprecated
error: deprecated environment variables detected
Please use a configuration file instead; visit https://www.rabbitmq.com/configure.html to learn more

之前的docker-compose-rabbitmq.yml文件如下:

version: '3'
services:
  rabbitmq:
    image: rabbitmq:3-management        # 镜像`rabbitmq:3-management` 【 注:该版本包含了web控制页面 】
    container_name: rabbitmq            # 容器名为'rabbitmq'
    hostname: my-rabbit
    restart: always                     # 指定容器退出后的重启策略为始终重启
    environment:                        # 设置环境变量,相当于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      RABBITMQ_DEFAULT_VHOST: my_vhost  # 主机名
      RABBITMQ_DEFAULT_USER: admin      # 登录账号
      RABBITMQ_DEFAULT_PASS: admin      # 登录密码
    ports:                              # 映射端口
      - "5672:5672"
      - "15672:15672"

二、出现问题原因

查看docker镜像说明:https://hub.docker.com/_/rabbitmq?tab=description&page=1&ordering=last_updated

警告:从 RabbitMQ 3.9 开始,下面列出的所有特定于 docker 的变量都已弃用且不再使用。请改用配置文件~

在这里插入图片描述
然后我们也可以看到今天此镜像有更新…
在这里插入图片描述

三、解决

1、换用其它未更新的版本镜像

在这里插入图片描述

docker-compose-rabbitmq.yml

version: '3'
services:
  rabbitmq:
    image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.7.8-management        # 原镜像`rabbitmq:3.7.8-management` 【 注:该版本包含了web控制页面 】
    container_name: rabbitmq            # 容器名为'rabbitmq'
    hostname: my-rabbit
    restart: always                     # 指定容器退出后的重启策略为始终重启
    environment:                        # 设置环境变量,相当于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      RABBITMQ_DEFAULT_VHOST: my_vhost  # 主机名
      RABBITMQ_DEFAULT_USER: admin      # 登录账号
      RABBITMQ_DEFAULT_PASS: admin      # 登录密码
    ports:                              # 映射端口
      - "5672:5672"
      - "15672:15672"

2、使用新镜像改用配置文件方式修改环境参数

可参考:https://gitee.com/zhengqingya/docker-compose
注:如果之前有安装过,需要清除浏览器缓存和删除rabbitmq相关的存储数据(如:这里映射到宿主机的data数据目录),再重装,否则会出现一定问题!

docker-compose-rabbitmq.yml

# 环境变量可参考: https://www.rabbitmq.com/configure.html
#               https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbit/docs/rabbitmq.conf.example
version: '3'
services:
  rabbitmq:
    image: registry.cn-hangzhou.aliyuncs.com/zhengqing/rabbitmq:3.9.1-management        # 镜像`rabbitmq:3.9.1-management` 【 注:该版本包含了web控制页面 】
    container_name: rabbitmq            # 容器名为'rabbitmq'
    hostname: my-rabbit
    restart: always                     # 指定容器退出后的重启策略为始终重启
    environment:                        # 设置环境变量,相当于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
    volumes:                            # 数据卷挂载路径设置,将本机目录映射到容器目录
      - "./rabbitmq/config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
      - "./rabbitmq/config/10-default-guest-user.conf:/etc/rabbitmq/conf.d/10-default-guest-user.conf"
      - "./rabbitmq/data:/var/lib/rabbitmq"
#      - "./rabbitmq/log:/var/log/rabbitmq"
    ports:                              # 映射端口
      - "5672:5672"
      - "15672:15672"

rabbitmq.conf

loopback_users.guest = false
listeners.tcp.default = 5672
default_vhost = my_vhost
default_user = admin
default_pass = admin
default_user_tags.administrator = true
default_permissions.configure = .*
default_permissions.read = .*
default_permissions.write = .*
hipe_compile = false
management.listener.port = 15672
management.listener.ssl = false

10-default-guest-user.conf

## DEFAULT SETTINGS ARE NOT MEANT TO BE TAKEN STRAIGHT INTO PRODUCTION
## see https://www.rabbitmq.com/configure.html for further information
## on configuring RabbitMQ

## allow access to the guest user from anywhere on the network
## https://www.rabbitmq.com/access-control.html#loopback-users
## https://www.rabbitmq.com/production-checklist.html#users
## loopback_users.guest = false

今日分享语句:
抱爱脚踏实地,为年轻喝彩。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_38225558/article/details/119354096

智能推荐

随便推点