Open
Description
Version(s)
1.5.4
Describe the bug
We have a scala-cli app that is packaged and used as docker image.
We are using a proxy(Nexus) for the docker registry where the images are pulled from first. However, the script always pulls the images from the docker public registry. This is causing a problem due to the rate limiting.
To Reproduce
- Create a base docker image into the local corp registry(e.g. Nexus)
You can create a new tag with a valid image. For example:
docker pull openjdk:20
docker tag openjdk:20 mycompany/openjdkyadu:20
docker push mycompany/openjdkyadu:20
- Now create a scala-cli script (
docker.scala
) that uses this newly created image
//> using packaging.dockerImageRegistry mycompany
//> using packaging.dockerFrom openjdkyadu:20
@main
def main() = {
println("Hello from docker app")
}
- Run the command
scala-cli --power package --docker docker.scala --docker-image-repository test-repo-docker
This generates the error:
Compiling project (Scala 3.5.2, JVM (11))
Compiled project (Scala 3.5.2, JVM (11))
Started building docker image with your application, it might take some time
Error: com.google.cloud.tools.jib.api.RegistryUnauthorizedException: Unauthorized for registry-1.docker.io/library/openjdkyadu
For more details, please see '/Users/yadu/temp/docker-test/.scala-build/stacktraces/1740994400-10899676711844464561.log'
Here is the log:
com.google.cloud.tools.jib.api.RegistryUnauthorizedException: Unauthorized for registry-1.docker.io/library/openjdkyadu
com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:163)
com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:434)
com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:439)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:181)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:71)
com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base@17.0.6/java.lang.Thread.run(Thread.java:833)
com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
com.google.cloud.tools.jib.http.ResponseException: 401 Unauthorized
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/openjdkyadu","Action":"pull"}]}]}
com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:355)
com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:266)
com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:138)
com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:434)
com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:439)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:181)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:71)
com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base@17.0.6/java.lang.Thread.run(Thread.java:833)
com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
com.google.api.client.http.HttpResponseException: 401 Unauthorized
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/openjdkyadu","Action":"pull"}]}]}
com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1113)
com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:349)
com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:266)
com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:138)
com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:434)
com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:439)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:181)
com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:71)
com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base@17.0.6/java.lang.Thread.run(Thread.java:833)
Expected behaviour
It should use the image from the local registry and don't go to public docker registry if its available in internal registry