3

I'm trying to run RabbitMQ in ECS on an AWSVPC network with EFS persistence.

The problem is that ECS on AWSVPC resets the hostname every time the container is restarted. This results in rabbitmq starting an entirely new directory in /var/lib/rabbitmq so it loses all of it's persistence.

Eg: starting it once, /var/lib/rabbitmq will contain:

drwxr-xr-x  4 100 root 6.0K Dec 23 13:00 rabbit@ip-10-0-12-171
-rw-r--r--  1 100 root   90 Dec 23 12:57 rabbit@ip-10-0-12-171-feature_flags
drwxr-xr-x 10 100 root 6.0K Dec 23 12:57 rabbit@ip-10-0-12-171-plugins-expand

The next time it starts the IP will change and everything else will just be dropped.


I've tried setting the HOSTNAME environment variable but that has no effect whatsoever.

I've tried setting RABBITMQ_MNESIA_DIR but after the second start the container just cycles and shows no obvious error message for me to post here.

I've tried setting RABBITMQ_NODENAME=rabbitmq@rabbitmq.dev.local (a route53 managed domain name) on the container. But that results in a puzzling error:

   [error] Supervisor net_sup had child net_kernel started with net_kernel:start_link(['rabbitmq@rabbitmq.dev.local',shortnames], false, net_sup_dynamic) at undefined exit with reason {'EXIT',nodistribution} in context start_error

The example on the dockerhub page just show setting the hostname. But because this is ECS on an AWSVPC I can't just set hostname in the container definition. As per the manual:

Note

The hostname parameter is not supported if you are using the awsvpc network mode.

I only need to convince rabbitmq the hostname is static. I don't care what the domain or hostname is externally, just what the the process inside the container thinks is the hostname. Is there any other way to set this other than the hostname in the task definition?

Philip Couling
  • 1,535
  • 1
  • 17
  • 32

1 Answers1

1

I got this working by using EFS for mnesia, setting RABBITMQ_NODENAME to "rabbit@localhost", and specifying the RABBITMQ_MNESIA_DIR.

      environment = [
        {
          name  = "RABBITMQ_NODENAME"
          value = "rabbit@localhost"
        },
        {
          name  = "RABBITMQ_MNESIA_DIR"
          value = "/var/lib/rabbitmq/mnesia/fox"
        }
      ]
      ...
      mountPoints = [
        {
          "containerPath" : "/var/lib/rabbitmq/mnesia",
          "sourceVolume" : "efs-rabbitmq-mnesia"
        }
      ]
      ...
    volume {
      name = "efs-rabbitmq-mnesia"
      efs_volume_configuration {
        file_system_id     = aws_efs_file_system.efs.id
        transit_encryption = "ENABLED"
        authorization_config {
          access_point_id = aws_efs_access_point.mnesia.id
        }
      }
    }
odie5533
  • 445
  • 1
  • 4
  • 7