@Override public void removeContainer(final String containerId) throws DockerException, InterruptedException { removeContainer(containerId, new RemoveContainerParam[0]); }
@Deprecated @Override public void removeContainer(final String containerId, final boolean removeVolumes) throws DockerException, InterruptedException { removeContainer(containerId, RemoveContainerParam.removeVolumes(removeVolumes)); }
@Override public void removeContainer(final String containerId) throws DockerException, InterruptedException { removeContainer(containerId, new RemoveContainerParam[0]); }
@Deprecated @Override public void removeContainer(final String containerId, final boolean removeVolumes) throws DockerException, InterruptedException { removeContainer(containerId, RemoveContainerParam.removeVolumes(removeVolumes)); }
public boolean removeContainer(String name) throws DockerCertificateException, DockerException, Exception { String id = getContainerIdByName(name); if (id != null) { this.client.removeContainer(id); } return id != null; }
/** * Remove the given container using the given retry policy. * * @param retryPolicy the retry policy in the event of failure * @param containerId the container id */ void removeContainer(String containerId, RetryPolicy retryPolicy) { Failsafe.with(retryPolicy) .onRetry(throwable -> LoggingUtil.INSTANCE.info( "Trying to remove Docker Container '{}'", containerId)) .onSuccess(result -> LoggingUtil.INSTANCE.info( "Docker Container '{}' removed", containerId)) .onFailure(throwable -> LoggingUtil.INSTANCE.error( "Docker Container '{}' could not be removed", containerId, throwable)) .run(() -> client.removeContainer(containerId)); }
public TaskExecutionResult executeTask(DockerTask task) throws Exception { if (!this.client.hasImage(task.getImage()) || task.isAlwaysPull()) { this.client.pullImage(task.getImage()); } String containerId = this.client.getContainerIdByName(task.getName()); if (containerId != null) { if (!task.isReuseContainer()) { // Delete it this.client.removeContainer(task.getName()); containerId = createContainer(task); } } else { containerId = createContainer(task); } log.info("Starting container " + containerId + " for task " + task.getName()); docker.startContainer(containerId); checkContainerCreationState(containerId); TaskExecutionResult result = collectTaskExecutionResult(task, containerId); if (!task.isKeepContainerAfterExecution() && !task.isReuseContainer()) { log.info("Removing finished container " + containerId); docker.removeContainer(containerId); } return result; }