void clean(final Id id) { if (id == null) { throw new IllegalArgumentException("id is null"); } stop(id); logger.info("Cleaning " + id); for (Container container : findAllContainers(id)) { logger.info("Removing container " + container.getId()); try { removeContainer(container); } catch (DockerException e) { throw new OrchestrationException(e); } } String imageId = null; try { imageId = findImageId(id); } catch (NotFoundException e) { logger.warn("Image " + id + " not found"); } catch (DockerException e) { throw new OrchestrationException(e); } if (imageId != null) { logger.info("Removing image " + imageId); try { docker.removeImageCmd(imageId).withForce().exec(); } catch (DockerException e) { logger.warn(e.getMessage()); } } }
public void stop() { for (Id id : repo.ids(true)) { if (!inclusive(id)) { continue; } stop(id); } }