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
- Upgrade the image tag to v22.2.1 or newer, e.g. redpandadata/redpanda:v23.1.2.
- Use DockerImageName.parse("redpandadata/redpanda:latest") or a recent pinned tag in tests.
- 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.
- 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
- Pin Redpanda image tags to >= v22.2.1 in one shared constant
- Use redpandadata/redpanda (not legacy vectorized/redpanda) images
- Centralize test image versions and review them when upgrading testcontainers
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
- This container's image does not have a healthcheck…
- Unexpected outputType
- you cannot specify a value smaller than 1 ms
- is not a valid Docker image name (in )
- is not a valid image versioning identifier (in )
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)