How to setup Jib container to authenticate with docker remote registry to pull images?
Asked Answered
T

1

0

Hi using Quarkus with Jib extension and setting: quarkus.jib.base-jvm-image=azul/zulu-openjdk-alpine:11

The build fails with the below error.

  1. I'm on Mac OS X, with Docker Desktop.
  2. This seems to have happened after updating Docker Desktop
  3. Running with sudo ./gradlew clean build --stacktrace -Dquarkus.container-image.build=true -Dquarkus.profile=dev works.
  4. Checked with ./docker-credential-osxkeychain list and my credentials are listed.
  5. Also looking at Docker Desktop I'm also logged in.
io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.container.image.jib.deployment.JibProcessor#buildFromJar threw an exception: java.lang.RuntimeException: Unable to create container image
        at io.quarkus.container.image.jib.deployment.JibProcessor.containerize(JibProcessor.java:240)
        at io.quarkus.container.image.jib.deployment.JibProcessor.buildFromJar(JibProcessor.java:166)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
  Caused by: com.google.cloud.tools.jib.api.RegistryAuthenticationFailedException: Failed to authenticate with registry registry-1.docker.io/azul/zulu-openjdk-alpine because: 401 Unauthorized
  GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:azul/zulu-openjdk-alpine:pull
  {"details":"incorrect username or password"}
  
        at com.google.cloud.tools.jib.registry.RegistryAuthenticator.authenticate(RegistryAuthenticator.java:305)
        at com.google.cloud.tools.jib.registry.RegistryAuthenticator.authenticate(RegistryAuthenticator.java:257)
        at com.google.cloud.tools.jib.registry.RegistryAuthenticator.authenticatePull(RegistryAuthenticator.java:176)
        at com.google.cloud.tools.jib.registry.RegistryClient.doBearerAuth(RegistryClient.java:334)
        at com.google.cloud.tools.jib.registry.RegistryClient.authPullByWwwAuthenticate(RegistryClient.java:393)
        at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:177)
        at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:69)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
  Caused by: com.google.cloud.tools.jib.http.ResponseException: 401 Unauthorized
  GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:azul/zulu-openjdk-alpine:pull
  {"details":"incorrect username or password"}
  
        at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:355)
        at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:266)
        at com.google.cloud.tools.jib.registry.RegistryAuthenticator.authenticate(RegistryAuthenticator.java:283)
        ... 12 more
  Caused by: com.google.api.client.http.HttpResponseException: 401 Unauthorized
  GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:azul/zulu-openjdk-alpine:pull
  {"details":"incorrect username or password"}
  
        at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
        at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:349)
        ... 14 more

Teodorateodorico answered 24/5, 2022 at 15:19 Comment(0)
T
1

Not exactly sure how it came about. But I erased my ~/.docker/docker.config and it works. I think on older Docker Desktop the keychain auth had to be manually setup and I guess updating made things screwy.

Teodorateodorico answered 24/5, 2022 at 19:20 Comment(1)
Make sense. Erasing config.json, you make sure Jib never picks up any credentials from it.Rhizomorphous

© 2022 - 2024 — McMap. All rights reserved.