简体   繁体   中英

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 . I tried with environmental variables first but when I logged into the management UI, all the default stuff is still there!

I then tried issuing the CMD and it still doesn't work:

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.

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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