当前位置:   article > 正文

docker部署rabbitmq出错touch: cannot touch ‘/etc/rabbitmq/rabbitmq.conf‘: Permission denied_touch: cannot touch 'daemon.json': permission deni

touch: cannot touch 'daemon.json': permission denied

docker部署rabbitmq出错touch: cannot touch ‘/etc/rabbitmq/rabbitmq.conf’: Permission denied

首先拉取镜像,这里我使用docker-compose直接拉取

version: '3'
services:

  rabbitmq:
    image: hub.commchina.net/library/rabbitmq:3.8.1-alpine
    container_name: rabbitmq
    environment:
      - RABBITMQ_DEFAULT_USER=admin
      - RABBITMQ_DEFAULT_PASS=admin
    restart: always
    ports:
      - "15672:15672"
    volumes:
      - ./rabbitmq/data:/var/lib/rabbitmq
      - ./rabbitmq/conf:/etc/rabbitmq
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

挂载的文件卷信息:

./rabbitmq/conf/rabbitmq.conf

loopback_users.guest = false
listeners.tcp.default = 5672
default_pass = admin
default_user = admin
management.tcp.port = 15672
  • 1
  • 2
  • 3
  • 4
  • 5

启动镜像:docker-compose -f docker-compose-rabbitmq.yaml up -d

报错信息如下

touch: cannot touch '/etc/rabbitmq/rabbitmq.conf': Permission denied
WARNING: '/etc/rabbitmq/rabbitmq.conf' is not writable, but environment variables have been provided which request that we write to it
  We have copied it to '/tmp/rabbitmq.conf' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead.

  • 1
  • 2
  • 3
  • 4

以为是权限不够所以加了–privileged=true还是不行

报错原因:最后发现是映射的目录./rabbitmq的conf和data没有创建修改权限
解决方法:
chmod说明(u:与文件属主拥有一样的权限[a:所有人];+:增加权限;rwx:可读可写可执行)-R:递归所有目录和文件

进入到rabbitmq的目录中,执行下面命令。意思就是改变data和conf文件夹的权限,使有权限访问此文件夹。

[root@monsvr rabbitmq]# chmod a+rwx -R data
[root@monsvr rabbitmq]# chmod a+rwx -R conf
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/823225
推荐阅读
相关标签
  

闽ICP备14008679号