java sdk管理docker 作者: juoliii 时间: 2024-06-25 分类: 开发 ```xml com.github.docker-java docker-java 3.3.6 com.github.docker-java docker-java-transport-httpclient5 3.3.6 ``` ```java DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("tcp://192.168.12.63:2375") .withDockerTlsVerify(false) // .withRegistryUrl("https://index.docker.io/v1/") // .withRegistryUsername("dockeruser") // .withRegistryPassword("ilovedocker") // .withRegistryEmail("dockeruser@github.com") .build(); DockerHttpClient httpClient= new ApacheDockerHttpClient .Builder() .dockerHost(config.getDockerHost()) .maxConnections(100) .connectionTimeout(Duration.ofSeconds(30)) .responseTimeout(Duration.ofSeconds(45)) .build(); DockerClient docker = DockerClientImpl.getInstance(config, httpClient); List containerList=docker.listContainersCmd().withShowAll(true).exec(); for (Container container : containerList) { System.out.println(container.getNames()[0]+" "+container.getState()); } ``` 标签: none
评论已关闭