我尝试在 Centos 7 上制作简单的 Docker-Java 应用程序。构建映像和容器调用成功。这是我的代码:
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());
}
}
但是我根本找不到 Docker 安全文件。Docker安装、构建镜像和容器调用都没有问题。但我不知道 Centos 7 中的 SSL 文件在哪里。这是异常消息
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)