{"record":{"id":"92d12327bd40caa3","repo":"theonedev/onedev","slug":"loopback-address-not-allowed-for-target-docker-ima","errorCode":null,"errorMessage":"Loopback address not allowed for target docker image of push image step, please use ip address or host name instead","messagePattern":"Loopback address not allowed for target docker image of push image step, please use ip address or host name instead","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/step/PushImageStep.java","lineNumber":78,"sourceCode":"\tpublic String getMoreOptions() {\n\t\treturn moreOptions;\n\t}\n\n\tpublic void setMoreOptions(String moreOptions) {\n\t\tthis.moreOptions = moreOptions;\n\t}\n\n\tstatic List<InputSuggestion> suggestVariables(String matchWith) {\n\t\treturn BuildSpec.suggestVariables(matchWith, true, true, false);\n\t}\n\n\t@Override\n\tpublic String getCommand() {\n\t\tvar builder = new StringBuilder(\"crane push\");\n\t\tif (getMoreOptions() != null)\n\t\t\tbuilder.append(\" \").append(getMoreOptions());\t\t\t\n\t\tif (getDestImage().contains(\"localhost\") || getDestImage().contains(\"127.0.0.1\"))\n\t\t\tthrow new ExplicitException(\"Loopback address not allowed for target docker image of push image step, please use ip address or host name instead\");\n\t\tbuilder.append(\" /onedev-build/work/\").append(getSrcPath()).append(\" \").append(getDestImage());\n\t\treturn builder.toString();\n\t}\n\t\n}\n","sourceCodeStart":60,"sourceCodeEnd":84,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/step/PushImageStep.java#L60-L84","documentation":"PushImageStep builds a 'crane push' command for publishing a docker image. Loopback addresses (localhost, 127.0.0.1) are rejected in destImage because the push runs inside the job container, where loopback would not point at the intended registry host. Any destImage containing those strings throws this ExplicitException.","triggerScenarios":"Configuring a PushImageStep whose destImage contains 'localhost' or '127.0.0.1' (substring check, so even 'my-localhost-registry:5000' triggers it).","commonSituations":"Copying a docker push config from local testing where localhost pointed at a local registry; intending an in-cluster registry but writing localhost instead of the registry service DNS name or pod IP.","solutions":["Replace 'localhost' in destImage with the registry host's IP address or DNS/host name reachable from the job executor.","Use the registry service name (e.g. registry.onedev-cluster.svc) or its cluster IP instead of loopback.","Rename any registry host whose name merely contains 'localhost' or '127.0.0.1' since the check is substring-based."],"exampleFix":"// before\n- type: PushImage\n  destImage: localhost:5000/myapp:1.0\n// after\n- type: PushImage\n  destImage: registry.mycompany.internal:5000/myapp:1.0","handlingStrategy":"validation","validationCode":"// Validate destImage in spec review or pre-step script\nif (destImage.contains(\"localhost\") || destImage.contains(\"127.0.0.1\")) {\n    throw new IllegalArgumentException(\"destImage must use a registry host name or IP, not loopback: \" + destImage);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use registry DNS names or routable IPs in CI image pushes, never localhost.","Keep local-test configs out of committed build specs.","Remember the check is substring-based; avoid host names containing 'localhost'."],"tags":["docker","ci","registry","network","build-spec"],"backgroundTag":"invalid-url","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}