當前位置: 首頁>>代碼示例>>Java>>正文


Java DockerClient.listContainers方法代碼示例

本文整理匯總了Java中com.spotify.docker.client.DockerClient.listContainers方法的典型用法代碼示例。如果您正苦於以下問題:Java DockerClient.listContainers方法的具體用法?Java DockerClient.listContainers怎麽用?Java DockerClient.listContainers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.spotify.docker.client.DockerClient的用法示例。


在下文中一共展示了DockerClient.listContainers方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshAll

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
@Override
public void refreshAll(PluginRequest pluginRequest) throws Exception {
    if (!refreshed) {
        DockerClient docker = docker(pluginRequest.getPluginSettings());
        List<Container> containers = docker.listContainers(DockerClient.ListContainersParam.withLabel(Constants.CREATED_BY_LABEL_KEY, Constants.PLUGIN_ID));
        for (Container container : containers) {
            register(DockerContainer.fromContainerInfo(docker.inspectContainer(container.id())));
        }
        refreshed = true;
    }
}
 
開發者ID:gocd-contrib,項目名稱:docker-elastic-agents,代碼行數:12,代碼來源:DockerContainers.java

示例2: removeContainers

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
private void removeContainers(DockerClient dockerClient, String imageName) throws DockerException, InterruptedException {
    log.debug("about to cleanup all containers created from image {}", imageName);
    List<Container> containers = dockerClient.listContainers(ListContainersParam.allContainers());
    for (Container container : containers) {
        if (imageName.equals(container.image())) {
            ContainerInfo containerInfo = dockerClient.inspectContainer(container.id());
            if (containerInfo.state().running()) {
                throw new IllegalStateException(String.format("container '%s' based on image '%s' is running, this test requires removing all containers created from image '%s'"));
            } else {
                log.debug("removing container {}", container.id());
                dockerClient.removeContainer(container.id());
            }
        }
    }
}
 
開發者ID:tdomzal,項目名稱:junit-docker-rule,代碼行數:16,代碼來源:DockerRuleImagePullTest.java

示例3: getImageFromRunningContainers

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
public static Object[] getImageFromRunningContainers(){
	DockerClient client = getDockerClient();
	List<String> images = new ArrayList<String>();
	try {
		List<Container> containers = client.listContainers();
		for(Container c:containers){
			images.add(c.image());
		}
	} catch (DockerException | InterruptedException e) {
		e.printStackTrace();
	}
	return images.toArray();
}
 
開發者ID:ipedrazas,項目名稱:eclipse-docker-plugin,代碼行數:14,代碼來源:DockerUtils.java

示例4: getRunningContainers

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
public static List<Container> getRunningContainers(){
	DockerClient client = getDockerClient();
	try {
		return client.listContainers();
	} catch (DockerException | InterruptedException e) {
		e.printStackTrace();
	}
	return new ArrayList<Container>();
}
 
開發者ID:ipedrazas,項目名稱:eclipse-docker-plugin,代碼行數:10,代碼來源:DockerUtils.java


注:本文中的com.spotify.docker.client.DockerClient.listContainers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。