我能够使用Remote API查询Docker主机:
curl https://<IP>:2376/images/json --cert cert.p12 --pass mypass --key key.pem --cacert ca.pem
有人可以帮助解决如何将这种curl REST调用转换为任何Java库代码的问题吗?
查看Jersey和HttpClient库,但似乎需要进行大量设置。
答案 0 :(得分:0)
检查docker-java
project是否有帮助。
Volume volume1 = new Volume("/opt/webapp1");
Volume volume2 = new Volume("/opt/webapp2");
CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withVolumes(volume1, volume2)
.withCmd("true").withBinds(new Bind("/src/webapp1", volume1, ro), new Bind("/src/webapp2", volume2))
.exec();
The Wiki提到证书:
DockerClient dockerClient = DockerClientBuilder.getInstance("http://localhost:2375").build();
// Or: Intialize docker client (advanced)
DockerClientConfig config = DockerClientConfig.createDefaultConfigBuilder()
.withUri("https://docker.somewhere.tld:2376")
.withDockerCertPath("/home/user/.docker")
.withUsername(registryUser)
.withPassword(registryPass)
.withEmail(registryMail)
.withServerAddress(registryUrl)
.build();
如your issue 483中所述,你要么:
pom.xml
dependencies,mvn dependency:list -DincludeScope=runtime
获取所有运行时依赖项的列表。