Skip to content

[Bug]: Starting RabbitMQContainer ignores RABBITMQ_DEFAULT_USER #10097

@svds86

Description

@svds86

Module

RabbitMQ

Testcontainers version

1.20.5+

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host Arch

x86

Docker version

Client: Docker Engine - Community
 Version:           28.0.1
 API version:       1.48
 Go version:        go1.23.6
 Git commit:        068a01e
 Built:             Wed Feb 26 10:42:11 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.0.1
  API version:      1.48 (minimum version 1.24)
  Go version:       go1.23.6
  Git commit:       bbd0a17
  Built:            Wed Feb 26 10:40:34 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.25
  GitCommit:        bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc:
  Version:          1.2.4
  GitCommit:        v1.2.4-0-g6c52b3f
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

Hi,

Since version 1.20.5 of the RabbitMQ testcontainer, the RABBITMQ_DEFAULT_USER is being ignored. The user will always be guest.

My configuration is:

private static final RabbitMQContainer RABBITMQ_CONTAINER = new RabbitMQContainer(
    DockerImageName.parse("rabbitmq:3.8-management").asCompatibleSubstituteFor("rabbitmq"))
    .withAdminPassword(null)
    .withExposedPorts(5671, 5672, 15672)
    .withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(
            new HostConfig().withPortBindings(
                    new PortBinding(Ports.Binding.bindPort(5671), new ExposedPort(5671)),
                    new PortBinding(Ports.Binding.bindPort(5672), new ExposedPort(5672)),
                    new PortBinding(Ports.Binding.bindPort(15672), new ExposedPort(15672))
            )
    ))
    .withLogConsumer(new Slf4jLogConsumer(RABBITMQ_LOGGER))
    .withEnv("RABBITMQ_DEFAULT_USER", "someuser")
    .withEnv("RABBITMQ_DEFAULT_PASS", "somepassword")
    .withEnv("RABBITMQ_DEFAULT_VHOST", "SOME_VHOST")
    .withReuse(true);

The following data is being used by the RabbitMQ container:

STDERR: Generated end result, for reference:
STDERR: ------------------------------------
STDERR: loopback_users.guest = false
STDERR: listeners.tcp.default = 5672
STDERR: default_pass = somepassword
STDERR: default_user = guest
STDERR: default_vhost = SOME_VHOST
STDERR: management.tcp.port = 15672

The following exception is being logged:

Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

I think it might be related to the following issue: #9570.

It works in version 1.20.4, but fails in version 1.20.5 and 1.20.6.

Relevant log output

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions