docker启动rabbit
docker run -d --hostname rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3.11-managment
报错:
failed to open log file at '/var/log/rabbitmq/rabbit@9f987b50c687_upgrade.log', reason: permission denied
启动时添加权限
# root权限--privileged=true -u root docker run -d --hostname rabbit -p 15672:15672 -p 5672:5672 --privileged=true -u root rabbitmq:3.11-managment
问题还在
解决:
启动空的rabbit把配置文件映射出来
docker run -d --hostname rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3.11-managment
mkdir -p /app/rabbit/etc mkdir -p /app/logs/rabbit
把rabbit配置文件复制到本地
docker cp -a 89a3a6aae4f0:/etc/rabbitmq /app/rabbit/etc docker cp -a 89a3a6aae4f0:/var/log/rabbitmq /app/logs/rabbit
docker stop rabbit docker rm rabbit
在本地映射的配置文件里配置
vim /app/rabbit/etc/conf.d/10-defaults.conf # 关闭控制台输出日志 log.console = false # 0点旋转文件 log.file.rotation.date = $D0 # 保留5个日志文件 log.file.rotation.count = 5
修改本地log目录权限
sudo chmod 777 -R /app/logs/rabbit
再次启动
docker run -d --hostname rabbit -p 15672:15672 -p 5672:5672 \ -v /app/rabbit/etc:/etc/rabbitmq \ -v /app/logs/rabbit:/var/log/rabbitmq rabbitmq:3.11-managment
成功