RabbitMQ in Docker - user creation not persisted -
RabbitMQ in Docker - user creation not persisted -
i've got problem user user1
not persisted in container have created using next dockerfile. reason this? rabbitmq specific issue? e.g. have explicitly specify user must persisted
from dockerfile/rabbitmq # define mount points. volume ["/data/log", "/data/mnesia"] # define working directory. workdir /data run (rabbitmq-start &) && \ sleep 10 && \ rabbitmqctl add_user user1 password1 && \ rabbitmqctl set_user_tags user1 administrator && \ rabbitmqctl set_permissions -p / user1 ".*" ".*" ".*" && \ sleep 10 && \ rabbitmqctl stop && \ sleep 10 # define default command. cmd ["rabbitmq-start"] # expose ports. expose 5672 expose 15672
i know it's old question, struggled hours problem today , solved me: issue seems due default hostname changing @ every new container docker, , rabbitmq binds configuration host name.
i set nodename variable in /etc/rabbitmq/rabbitmq-env.conf before setting user:
# create node name static run echo 'nodename=rabbit@localhost' > /etc/rabbitmq/rabbitmq-env.conf
and works.
hope can help.
edit:
here working dockerfile (copying rabbitmq-env.conf file container):
from ubuntu:latest run groupadd -r rabbitmq && useradd -r -d /var/lib/rabbitmq -m -g rabbitmq rabbitmq # add together rabbitmq repo run apt-get update && \ apt-get install wget --assume-yes && \ wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc && \ sudo apt-key add together rabbitmq-signing-key-public.asc && \ sed -i -e '1ideb http://www.rabbitmq.com/debian/ testing main\' /etc/apt/sources.list && \ apt-get update && \ apt-get install rabbitmq-server --assume-yes # enable plugins run rabbitmq-plugins enable rabbitmq_management && \ rabbitmq-plugins enable rabbitmq_web_stomp && \ rabbitmq-plugins enable rabbitmq_mqtt # expose ports # management expose 15672 # web-stomp plugin expose 15674 # mqtt: expose 1883 # configure rabbitmq re-create ["rabbitmq-env.conf", "/etc/rabbitmq/rabbitmq-env.conf"] run chmod 755 /etc/rabbitmq/rabbitmq-env.conf # create users apps re-create ["rabbitmq-setup.sh", "/tmp/rabbitmq/rabbitmq-setup.sh"] run mkdir /var/run/rabbitmq && \ chmod -r 755 /var/run/rabbitmq && \ chown -r rabbitmq:rabbitmq /var/run/rabbitmq && \ service rabbitmq-server start && \ sh /tmp/rabbitmq/rabbitmq-setup.sh && \ rm /tmp/rabbitmq/rabbitmq-setup.sh && \ service rabbitmq-server stop # start rabbitmq user rabbitmq cmd ["rabbitmq-server", "start"]
my rabbitmq-env.conf file:
nodename=rabbimq@localhost
my rabbitmq-setup.sh:
rabbitmqctl add_vhost myvhost && rabbitmqctl add_user myuser mypasswd && rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*" && rabbitmqctl set_user_tags myuser administrator
rabbitmq docker
Comments
Post a Comment