testcontainers/testcontainers-java · error · IllegalArgumentException

Redpanda version must be >= v22.2.1

Error message

Redpanda version must be >= v22.2.1

What it means

RedpandaContainer's constructor validates the image tag of the Redpanda docker image being used. Images on the redpandadata/vectorized official repositories older than v22.2.1 are not supported by Testcontainers, so it throws IllegalArgumentException at construction time. The check only applies to the known public compatible image names.

Solutions

  1. Upgrade the image tag to v22.2.1 or newer, e.g. redpandadata/redpanda:v23.1.2.
  2. Use DockerImageName.parse("redpandadata/redpanda:latest") or a recent pinned tag in tests.
  3. If you must test against an old broker, bypass via new RedpandaContainer(DockerImageName.parse(...).asCompatibleSubstituteFor("redpandadata/redpanda")) — only if you accept it may not work.
  4. Update any CI config or docker-compose-derived version strings feeding the container constructor.

Example fix

// before
RedpandaContainer container = new RedpandaContainer("vectorized/redpanda:v21.11.9");
// after
RedpandaContainer container = new RedpandaContainer(DockerImageName.parse("redpandadata/redpanda:v23.1.2"));
Defensive patterns

Strategy: validation

Validate before calling

DockerImageName img = DockerImageName.parse(image);
String version = img.getVersionPart(); // e.g. v23.1.2
if (version.compareTo("v22.2.1") < 0) throw new IllegalArgumentException("Redpanda image must be >= v22.2.1: " + image);

Try / catch

try {
  RedpandaContainer c = new RedpandaContainer(imageName);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Redpanda version must be")) {
    throw new ConfigurationException("Upgrade Redpanda image to >= v22.2.1, got: " + imageName); }
  throw e;
}

Prevention

When it happens

Trigger: Creating new RedpandaContainer(DockerImageName.parse("vectorized/redpanda:v21.x")) or any tag whose version part is less than v22.2.1, e.g. v22.1.x or older, via new RedpandaContainer("redpandadata/redpanda:v22.1.1").

Common situations: Projects pinned to old Redpanda versions in build scripts, upgrading testcontainers but keeping an old image tag, or copying tutorial code with a legacy vectorized/redpanda image.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/7d9f2946496a3ba4. Report an issue: GitHub.

Appendix: source

Thrown at modules/redpanda/src/main/java/org/testcontainers/redpanda/RedpandaContainer.java:86

    @Deprecated
    private final Set<Supplier<Listener>> listenersValueSupplier = new HashSet<>();

    private final Map<String, Supplier<String>> listeners = new HashMap<>();

    public RedpandaContainer(String image) {
        this(DockerImageName.parse(image));
    }

    public RedpandaContainer(DockerImageName imageName) {
        super(imageName);
        imageName.assertCompatibleWith(REDPANDA_IMAGE, IMAGE);

        boolean isLessThanBaseVersion = new ComparableVersion(imageName.getVersionPart()).isLessThan("v22.2.1");
        boolean isPublicCompatibleImage =
            REDPANDA_FULL_IMAGE_NAME.equals(imageName.getUnversionedPart()) ||
            IMAGE_NAME.equals(imageName.getUnversionedPart());
        if (isPublicCompatibleImage && isLessThanBaseVersion) {
            throw new IllegalArgumentException("Redpanda version must be >= v22.2.1");
        }

        withExposedPorts(REDPANDA_PORT, REDPANDA_ADMIN_PORT, SCHEMA_REGISTRY_PORT, REST_PROXY_PORT);
        withCreateContainerCmdModifier(cmd -> {
            cmd.withEntrypoint("/entrypoint-tc.sh");
            cmd.withUser("root:root");
        });
        waitingFor(Wait.forLogMessage(".*Successfully started Redpanda!.*", 1));
        withCopyFileToContainer(
            MountableFile.forClasspathResource("testcontainers/entrypoint-tc.sh", 0700),
            "/entrypoint-tc.sh"
        );
        withCommand("redpanda", "start", "--mode=dev-container", "--smp=1", "--memory=1G");
    }

    @Override
    protected void configure() {
        this.listenersValueSupplier.stream()

View on GitHub (pinned to 8e549514e3)