ContainerConfig containerConfig = new ContainerConfig();
containerConfig.setImage(testImage);
containerConfig.setCmd(new String[] { "echo" });
ContainerCreateResponse container1 = dockerClient
.createContainer(containerConfig);
assertThat(container1.getId(), not(isEmptyString()));
ContainerInspectResponse containerInspectResponse = dockerClient.inspectContainer(container1.getId());
assertThat(containerInspectResponse.getConfig().getImage(), is(equalTo(testImage)));
dockerClient.startContainer(container1.getId());
tmpContainers.add(container1.getId());
LOG.info("container id: " + container1.getId());
List<Container> containers2 = dockerClient.listContainers(true);
for(Container container: containers2) {
LOG.info("listContainer: id=" + container.getId() +" image=" + container.getImage());
}
assertThat(size + 1, is(equalTo(containers2.size())));
Matcher matcher = hasItem(hasField("id", startsWith(container1.getId())));
assertThat(containers2, matcher);
List<Container> filteredContainers = filter(
hasField("id", startsWith(container1.getId())), containers2);
assertThat(filteredContainers.size(), is(equalTo(1)));
for(Container container: filteredContainers) {
LOG.info("filteredContainer: " + container.getImage());
}