I am using this container like following
docker run \
--restart always \
--name rabbitmq1 \
-p 5672:5672 \
-p 15672:15672 \
-e RABBITMQ_DEFAULT_USER=sca \
-e RABBITMQ_DEFAULT_PASS=passwordhere \
-v /docker-data/rabbitmq1/data:/var/lib/rabbitmq \
-d rabbitmq:management
I am trying to persist the data (like exchanges, users, vhost, etc..) across container re-run, but, it seems to create a brand new mnesia directory under /var/lib/rabbitmq everytime I re-run the container so all data is lost.. How can I make sure that users, vhost, etc.. won't get wiped out everytime I rebuild the container?
Rabbitmq uses the hostname as part of the folder name in the mnesia directory. Maybe add a --hostname some-rabbit to your docker run?
@yosifkit it's perfectly fine to override it. In fact, I think this image should do just that. The only reason why we still do it is because migrating existing installations reliably is really non-trivial: there can be all kinds of customizations and different OSes, installation methods, etc :(
@yosifkit Thanks, that did it.
I think it will be nice if this container displayed some kind of glaring warning / or not even start the container without setting the hostname.
Question on this.. I've got the same issue, but giving it a hostname didn't change anything... Here's what I'm doing:
Then I go into the mq console, and add a persisent queue called "ben_test".
I commit the container using:
docker commit rabbit_dev rabbitmq:3-management
I stop the existing container.
I re-run:
docker run -d --hostname my-rabbit --name rabbit_dev -p 8088:15672 -p 8087:5672 rabbitmq:3-management
Here I expect to see the queue I already created, but I don't. I just see a brand new, empty version of rabbitmq.
Using "docker commit" won't save the contents of the volumes (which is
where the persistent state lives). Use a named volume or a bind-mount and
you should be able to persist your data between container runs.
Can you give me a syntax example of that?
From: Tianon Gravi notifications@github.com
Sent: Wednesday, April 11, 2018 12:34 PM
To: docker-library/rabbitmq rabbitmq@noreply.github.com
Cc: June, Ben b.june@northeastern.edu; Comment comment@noreply.github.com
Subject: Re: [docker-library/rabbitmq] Won't persist data (#106)
Using "docker commit" won't save the contents of the volumes (which is
where the persistent state lives). Use a named volume or a bind-mount and
you should be able to persist your data between container runs.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/docker-library/rabbitmq/issues/106#issuecomment-380515997, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AkhPcRkiYaKj5nx-g6ftQqq8LQ7SnpwVks5tnjB5gaJpZM4JrYUe.
$ docker run -v rabbitmq-data:/var/lib/rabbitmq -d --hostname my-rabbit --name rabbit_dev -p 8088:15672 -p 8087:5672 rabbitmq:3-management
Oh I get it now… running w/ a volume will create that volume locally (docker server) and then be saved and re-usable as long as I:
Commit the changes after I make config changes
Startup the container using the same volume each time
Is that accurate?
From: Tianon Gravi notifications@github.com
Sent: Wednesday, April 11, 2018 12:40 PM
To: docker-library/rabbitmq rabbitmq@noreply.github.com
Cc: June, Ben b.june@northeastern.edu; Comment comment@noreply.github.com
Subject: Re: [docker-library/rabbitmq] Won't persist data (#106)
$ docker run -v rabbitmq-data:/var/lib/rabbitmq -d --hostname my-rabbit --name rabbit_dev -p 8088:15672 -p 8087:5672 rabbitmq:3-management
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/docker-library/rabbitmq/issues/106#issuecomment-380517986, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AkhPcRwRNfEQSuTzmVyxgunKPftkXWP7ks5tnjHygaJpZM4JrYUe.
Yep. In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
I'm going to close since the original issue here appears to be solved. :+1:
Most helpful comment
Rabbitmq uses the hostname as part of the folder name in the mnesia directory. Maybe add a
--hostname some-rabbitto your docker run?