Rabbitmq: Won't persist data

Created on 23 Aug 2016  Â·  9Comments  Â·  Source: docker-library/rabbitmq

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?

Most helpful comment

Rabbitmq uses the hostname as part of the folder name in the mnesia directory. Maybe add a --hostname some-rabbit to your docker run?

All 9 comments

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:

  1. Starting mq container with nothing configured using:
    docker run -d --hostname my-rabbit --name rabbit_dev -p 8088:15672 -p 8087:5672 rabbitmq:3-management
  2. Then I go into the mq console, and add a persisent queue called "ben_test".

  3. I commit the container using:

    docker commit rabbit_dev rabbitmq:3-management

  4. I stop the existing container.

  5. I re-run:
    docker run -d --hostname my-rabbit --name rabbit_dev -p 8088:15672 -p 8087:5672 rabbitmq:3-management

  6. 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:

  1. Commit the changes after I make config changes

  2. 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:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CVTJNII picture CVTJNII  Â·  4Comments

michaelkrog picture michaelkrog  Â·  5Comments

bloodybeet picture bloodybeet  Â·  3Comments

LanceGG picture LanceGG  Â·  5Comments

fanhualei picture fanhualei  Â·  4Comments