-
Notifications
You must be signed in to change notification settings - Fork 816
Description
RabbitMQ uses its HOSTNAME to set up paths for queues on its internal storage. As the DCP generates a random hostname across restarts, this changes with every invocation of the container. This results in unexpected behavior from the developer's point of view - queues are not persisted across restarts even with persistent storage configured for the container.
This is an example of a statement that will NOT persist queues:
var rabbitMq = builder
.AddRabbitMQContainer("rabbitmq-host", 5672, password: rabbitMqPassword)
.WithVolumeMount("rabbitmq-host-vol", "/var/lib/rabbitmq", VolumeMountType.Named);
If a NODENAME environment variable is set, RabbitMQ uses that to override the HOSTNAME on the container for internal configuration purposes. So directly specifiying the NODENAME variable With i.e. WithEnvironment("NODENAME", "rabbit@localhost") resolves the issue, as in the following statement:
var rabbitMq = builder
.AddRabbitMQContainer("rabbitmq-host", 5672, password: rabbitMqPassword)
.WithEnvironment("NODENAME", "rabbit@localhost")
.WithVolumeMount("rabbitmq-host-vol", "/var/lib/rabbitmq", VolumeMountType.Named);
Suggestion : set NODENAME by default to a fixed value for RabbitMQ hosts (it's only used internally, so won't affect other RabbitMQ containers running in the same docker engine) - but still allow the user to override by setting it specifically like above. Alternatively, as a minimum, update the RabbitMQ container documentation for Aspire to mention this specifically.