Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ~/. docker/config.json with auths null throws an error #7296

Closed
bauernknecht opened this issue Jul 4, 2023 · 17 comments
Closed

[Bug]: ~/. docker/config.json with auths null throws an error #7296

bauernknecht opened this issue Jul 4, 2023 · 17 comments
Labels

Comments

@bauernknecht
Copy link

Module

Core

Testcontainers version

1.18.1

Using the latest Testcontainers version?

No

Host OS

Windows

Host Arch

x64

Docker version

Client:
 Cloud integration: v1.0.35
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:15 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.21.0 (113844)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:17 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

Running integrations test would not work because testcontainers could not start. The error is caused by a null value in dockers config.json. I recently did a fresh install of Docker Desktop so that my previous config.json most likey got replaced/deleted. The freshly created config.json looks like this:

{ "auths": null, "credsStore": "desktop", "plugins": { "-x-cli-hints": { "enabled": "true" } } }

After fiddling around i replaced the null value for "auths" with an empty object and it worked flawlessly. My config.json now looks like this:

{ "auths": {}, "credsStore": "desktop", "plugins": { "-x-cli-hints": { "enabled": "true" } } }

Relevant log output

java.util.ServiceConfigurationError: org.testcontainers.dockerclient.DockerClientProviderStrategy: Provider org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy could not be instantiated

    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
    at java.base/java.lang.Iterable.forEach(Iterable.java:74)
    at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:148)
    at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:186)
    at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104)
    at com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:128)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeAllMethod(TimeoutExtension.java:70)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllMethods$13(ClassBasedTestDescriptor.java:411)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllMethods(ClassBasedTestDescriptor.java:409)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:215)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:84)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Map.entrySet()" because the return value of "org.testcontainers.shaded.com.github.dockerjava.core.DockerConfigFile.getAuths()" is null
    at org.testcontainers.shaded.com.github.dockerjava.core.DockerConfigFile.loadConfig(DockerConfigFile.java:158)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultDockerClientConfig$Builder.readDockerConfig(DefaultDockerClientConfig.java:470)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultDockerClientConfig$Builder.build(DefaultDockerClientConfig.java:457)
    at org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy.<init>(EnvironmentAndSystemPropertyClientProviderStrategy.java:57)
    at org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy.<init>(EnvironmentAndSystemPropertyClientProviderStrategy.java:34)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
    ... 69 more

Additional Information

No response

@ieu
Copy link

ieu commented Jul 4, 2023

Im encounting the same issue. Manually modifying config.json works.

@Yashasvi191
Copy link

I am getting the same issue. What is the solution for this?

@eddumelendez
Copy link
Member

The issue belong to docker-java, I have created docker-java/docker-java#2138

@eddumelendez eddumelendez closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2023
@chunweilim
Copy link

chunweilim commented Jul 9, 2023

I am getting the same issue. What is the solution for this?

Update your config.json in the .docker folder from "auths": null to "auths": {}.

This works for me on testcontainers version 1.18.3 and Docker Desktop for Windows version 4.21.1.

@AndyGee
Copy link

AndyGee commented Jul 13, 2023

Can also confirm after a fresh Docker Desktop 4.21.1 (114176) install that this issue is in 1.18.3 - The suggested "auths": {} fix works

@AjiLeight
Copy link

which .docker folder? can anyone show me a relative path?

@AndyGee
Copy link

AndyGee commented Jul 18, 2023

~/. docker/config.json

@nurena24
Copy link

Im encounting the same issue. Manually modifying config.json works.

@AXE-00
Copy link

AXE-00 commented Jul 26, 2023

You are a life saver. works perfectly, thanks

@eddumelendez eddumelendez changed the title [Bug]: [Bug]: ~/. docker/config.json with auths null throws an error Jul 26, 2023
@AlexeySudakovJD34
Copy link

I have the same issue but no config.json file in folder .docker (((

@AXE-00
Copy link

AXE-00 commented Jul 29, 2023

try creating one

I have the same issue but no config.json file in folder .docker (((
Try creating one.
paste this in it.

{
"auths": {},
"credsStore": "desktop",
"plugins": {
"-x-cli-hints": {
"enabled": "true"
}
}
}

@AlexeySudakovJD34
Copy link

AlexeySudakovJD34 commented Jul 29, 2023

Done as suggested, but looks like error still exists:

Cannot invoke "java.util.Map.entrySet()" because the return value of "com.github.dockerjava.core.DockerConfigFile.getAuths()" is null

@gesellix
Copy link
Contributor

Please try replacing

...
"auths": {},
...

with

...
"auths": {
        "https://index.docker.io/v1/": {}
 },
...

@AlexeySudakovJD34
Copy link

It was my mistake in dir identification for config.json revision... This file (with 'null') existed from the very Docker Desktop installation but I looked in wrong folder.
Right file identified, "auths" adjusted from 'null' to '{}' and tests finished successfully. Your initial solution works. Thanks a lot.

@XedinUnknown
Copy link

FYI to save you a Google: Windows users will find the config file in %USERPROFILE%\.docker.

@kiview
Copy link
Member

kiview commented Aug 18, 2023

Just to be explicit, this issue will be automatically fixed in Testcontainers for Java once we use the new docker-java version that contains the fix 👍

@eddumelendez
Copy link
Member

I should have closed this one once #7423 was merged 😬

There will be a new release on Monday and it will include docker-java 3.3.3 which container this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests