Docker Community Forums

Share and learn in the Docker community.

Com.github.dockerjava.api.exception.DockerClientException: Certificate path (DOCKER_CERT_PATH) '/root/.docker/certs' doesn't exist


(Gladiator67) #1

I try to make simple docker-java application on centos 7. Building image and container invocation are successful. This is my codes

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("user01@naver.com")
                .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)

Your advice will be deeply appreciated. Thanks


(Nathan Le Claire) #2

Is the daemon actually running using tls-related flags? Inspect ps aux | grep docker to see.

If not exposing the Docker API using TLS (which is usually the case when listening on the UNIX socket), you can just skip specifying the Docker cert path since you aren’t using it (so, remove withDockerCertPath line above). Right now you’re trying to tell the Docker client that there are certificates for connection available at /root/.docker/certs, which is a directory that doesn’t exist. Therefore, your client gets confused.