2

I try to make simple Docker-Java application on Centos 7. Building image and container invocation are successful. This is my code:

    public class JavaClient {

    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
        DockerClientConfig config = DockerClientConfig.createDefaultConfigBuilder()
                    .withRegistryUrl("unix:///var/run/docker.sock")
                    .withDockerCertPath("/root/.docker/certs")
                    .withRegistryUsername("user01")
                    .withRegistryPassword("111111")
                    .withRegistryEmail("[email protected]")
                    .build();

        DockerClient dockerClient = DockerClientBuilder.getInstance(config).build();

        System.out.println(dockerClient.versionCmd());

    }

 }

However I can't find the Docker security files at all. Docker installation, building images and container invocation have no problem. But I don't know where SSL files in Centos 7 are. This is the exception message

Exception in thread "main" com.github.dockerjava.api.exception.DockerClientException: Certificate path (DOCKER_CERT_PATH) '/root/.docker/certs' doesn't exist.
at com.github.dockerjava.core.DockerClientConfig.checkDockerCertPath(DockerClientConfig.java:112)
at com.github.dockerjava.core.DockerClientConfig.(DockerClientConfig.java:85)
at com.github.dockerjava.core.DockerClientConfig$DockerClientConfigBuilder.build(DockerClientConfig.java:432)
at com.aaa.docker.JavaClient.main(JavaClient.java:18)

1 Answer 1

1

You can just create empty directory '/root/.docker/certs'.

I found another solution which not requires to create directories. You can just create properties, like environment variables and set DOCKER_TLS_VERIFY to "0". In this case, docker won't look for any certificates.

final Properties properties = new Properties();
    properties.setProperty("DOCKER_TLS_VERIFY", "0");
    properties.setProperty("DOCKER_HOST", "unix:///var/run/docker.sock");
    final DockerClientConfig.DockerClientConfigBuilder configBuilder = new DockerClientConfig.DockerClientConfigBuilder().withProperties(properties);
    return DockerClientBuilder.getInstance(configBuilder).build();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.