简体   繁体   English

无法删除默认用户、密码和 Vhost - RabbitMQ Dockerfile

[英]Cannot Delete Default User, Password, and Vhost - RabbitMQ Dockerfile

I'm trying to write a Dockerfile that copies a custom conf and sets the default user, password, and vhost to something other than / guest guest .我试图写一个Dockerfile那份定制conf并设置默认的用户名,密码和虚拟主机比其他的东西/ guest guest I tried with environmental variables first but when I logged into the management UI, all the default stuff is still there!我首先尝试使用环境变量,但是当我登录管理 UI 时,所有默认的东西仍然存在!

I then tried issuing the CMD and it still doesn't work:然后我尝试发出CMD但它仍然不起作用:

FROM rabbitmq:3.8.2-management

#ENV RABBITMQ_DEFAULT_USER=test
#ENV RABBITMQ_DEFAULT_PASS=test
#ENV RABBITMQ_DEFAULT_VHOST=test

COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf

CMD ["sh", "-c", "rabbitmq-plugins enable rabbitmq_auth_backend_http; rabbitmq-server", "rabbitmqctl add_user test test", "rabbitmqctl set_user_tags test administrator", "rabbitmqctl delete_user guest", "rabbitmqctl delete_vhost /", "rabbitmqctl add_vhost testvhost", "rabbitmqctl set_permissions -p test testvhost \".*\" \".*\" \".*\""]

I found if I bash into the container after its spun up and run rabbitmqctl add_user test test it does add the new user.我发现如果我在容器启动后猛击容器并运行rabbitmqctl add_user test test它会添加新用户。

What am I doing wrong?我究竟做错了什么?

It looks as though because I am overriding the conf with my own configuration in /etc/rabbitmq/rabbitmq.conf the ENV vars don't seem to be having an effect on the default user , password , and vhost .看起来好像是因为我在/etc/rabbitmq/rabbitmq.conf中用我自己的配置覆盖了conf ,所以ENV变量似乎对默认userpasswordvhost

My solution was to put them in my configuration:我的解决方案是将它们放在我的配置中:

loopback_users.guest = false
listeners.tcp.default = 5672
management.listener.port = 15672
default_user = test
default_pass = test
default_vhost = test

I hope this helps anyone else in this situation.我希望这可以帮助其他人在这种情况下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM