Refactoring of DockerClientConfig by marcuslinke · Pull Request #447 · docker-java/docker-java
Btw, how AuthCmd should work?
final AuthConfig authConfig = new AuthConfig();
authConfig.setPassword("docker-registry-password");
authConfig.setUsername("docker-registry-login");
authConfig.setEmail("sdf@sdf.com");
authConfig.setServerAddress(String.format("%s:%d", d.getHost(), nginxContainer.getExposedPort()));
DockerClientConfig clientConfig = new DockerClientConfig.DockerClientConfigBuilder()
// .withUsername("docker-registry-login")
// .withServerAddress(String.format("http://%s:%d", d.getHost(), nginxContainer.getExposedPort()))
.withUri(String.format("http://%s:44447", d.getHost()))
.build();
DockerCmdExecFactoryImpl dockerCmdExecFactory = new DockerCmdExecFactoryImpl()
.withReadTimeout(0)
.withConnectTimeout(10000);
DockerClient dockerClient = DockerClientBuilder.getInstance(clientConfig)
.withDockerCmdExecFactory(dockerCmdExecFactory)
.build();
final AuthResponse authResponse = dockerClient.authCmd()
.withAuthConfig(authConfig)
.exec();
LOG.debug(authResponse.getStatus());
With uncommented lines fails because authCmd() checks for username+server:
java.lang.NullPointerException: Configured username is null.
at com.github.kostyasha.yad.docker_java.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:226)
at com.github.kostyasha.yad.docker_java.com.github.dockerjava.core.DockerClientImpl.authConfig(DockerClientImpl.java:141)
at com.github.kostyasha.yad.docker_java.com.github.dockerjava.core.DockerClientImpl.authCmd(DockerClientImpl.java:162)
And it impossible to set new auth with later command.