{"record":{"id":"e54d122705b8bca4","repo":"testcontainers/testcontainers-java","slug":"repository-is-not-a-valid-docker-image-name-in-rawname","errorCode":null,"errorMessage":"${repository} is not a valid Docker image name (in ${rawName})","messagePattern":"(.+?) is not a valid Docker image name \\(in (.+?)\\)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/testcontainers/utility/DockerImageName.java","lineNumber":216,"sourceCode":"        }\n        return getUnversionedPart() + versioning.getSeparator() + getVersionPart();\n    }\n\n    @Override\n    public String toString() {\n        return asCanonicalNameString();\n    }\n\n    /**\n     * Is the image name valid?\n     *\n     * @throws IllegalArgumentException if not valid\n     */\n    public void assertValid() {\n        //noinspection UnstableApiUsage\n        HostAndPort.fromString(registry); // return value ignored - this throws if registry is not a valid host:port string\n        if (!REPO_NAME.matcher(repository).matches()) {\n            throw new IllegalArgumentException(repository + \" is not a valid Docker image name (in \" + rawName + \")\");\n        }\n        if (!versioning.isValid()) {\n            throw new IllegalArgumentException(\n                versioning + \" is not a valid image versioning identifier (in \" + rawName + \")\"\n            );\n        }\n    }\n\n    /**\n     * @param newTag version tag for the copy to use\n     * @return an immutable copy of this {@link DockerImageName} with the new version tag\n     */\n    public DockerImageName withTag(final String newTag) {\n        return withVersioning(new TagVersioning(newTag));\n    }\n\n    /**\n     * Declare that this {@link DockerImageName} is a compatible substitute for another image - i.e. that this image","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/utility/DockerImageName.java#L198-L234","documentation":"DockerImageName.assertValid() validates that the parsed repository part matches Docker's repository-name regex. If it doesn't, it throws IllegalArgumentException stating the repository is not a valid Docker image name, including the original raw name. This guards against images with malformed names being sent to the Docker daemon.","triggerScenarios":"Calling DockerImageName.parse(...).assertValid() (directly or transitively when a container starts) with a name whose repository portion violates Docker naming rules — uppercase letters in the repo path, illegal characters, empty segments, etc.","commonSituations":"Typo'd image names with uppercase (e.g. 'MyApp:latest'); interpolated variables left empty producing names like '/:tag'; mistaking registry-qualified names for repo rules; concatenating prefix strings incorrectly.","solutions":["Check the rawName in the message and fix the image string to a valid Docker repository name (lowercase alphanumerics, '.', '_', '/', optional registry).","Uppercase is only allowed in the registry host part — lowercase the repository portion or move the case-sensitive part into a tag/label.","Validate the name early with DockerImageName.parse(raw).assertValid() in your own setup code to fail fast with context."],"exampleFix":"// before\nDockerImageName.parse(\"MyApp:1.0\").assertValid();\n// after\nDockerImageName.parse(\"myapp:1.0\").assertValid();","handlingStrategy":"validation","validationCode":"static final Pattern REPO = Pattern.compile(\"^[a-z0-9]+(?:(?:[._]|__|[-]*)[a-z0-9]+)*(?:/[a-z0-9]+(?:(?:[._]|__|[-]*)[a-z0-9]+)*)*$\");\nif (!REPO.matcher(repository).matches()) throw new IllegalArgumentException(\"Invalid repo: \" + repository);","typeGuard":null,"tryCatchPattern":"try {\n    imageName.assertValid();\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException(\"Fix image name: \" + e.getMessage(), e);\n}","preventionTips":["Lowercase all repository portions of image names","Validate interpolated image strings before parsing","Call assertValid() early in setup to fail fast with context"],"tags":["validation","docker-image","naming"],"backgroundTag":"invalid-identifier-format","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}