@Override protected Void execute(StopContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/stop").resolveTemplate("id", command.getContainerId()); if (command.getTimeout() != null) { webResource = webResource.queryParam("t", String.valueOf(command.getTimeout())); } LOGGER.trace("POST: {}", webResource); webResource.request().accept(MediaType.APPLICATION_JSON).post(null).close(); return null; } }
public void stopContainer(String containerId) { this.readWriteLock.readLock().lock(); try { this.dockerClient.stopContainerCmd(containerId).exec(); } finally { this.readWriteLock.readLock().unlock(); } }
private void stop(final Id id) { if (id == null) { throw new IllegalArgumentException("id is null"); } logger.info("Stopping " + id); for (Container container : findRunningContainers(id)) { logger.info("Stopping container " + Arrays.toString(container.getNames())); try { docker.stopContainerCmd(container.getId()).withTimeout(1).exec(); } catch (DockerException e) { throw new OrchestrationException(e); } } for (Plugin plugin : plugins) { plugin.stopped(id, conf(id)); } }
/** * Produces a stop container request * * @param client * @param message * @return */ private StopContainerCmd executeStopContainerRequest(DockerClient client, Message message) { LOGGER.debug("Executing Docker Stop Container Request"); String containerId = DockerHelper.getProperty(DockerConstants.DOCKER_CONTAINER_ID, configuration, message, String.class); StopContainerCmd stopContainerCmd = client.stopContainerCmd(containerId); Integer timeout = DockerHelper.getProperty(DockerConstants.DOCKER_TIMEOUT, configuration, message, Integer.class); if (timeout != null) { stopContainerCmd.withTimeout(timeout); } return stopContainerCmd; }
public void stop(String containerId) { docker.stopContainerCmd(containerId).exec(); startedContainers.remove(containerId); }
@Override public void stopContainer(ContainerName containerName) { try { dockerClient.stopContainerCmd(containerName.asString()).withTimeout((int) WAIT_BEFORE_KILLING.getSeconds()).exec(); } catch (NotFoundException e) { throw new ContainerNotFoundException(containerName); } catch (NotModifiedException ignored) { // If is already stopped, ignore } catch (RuntimeException e) { numberOfDockerDaemonFails.add(); throw new DockerException("Failed to stop container '" + containerName.asString() + "'", e); } }
public void stopContainer(String containerId) { this.readWriteLock.readLock().lock(); try { this.dockerClient.stopContainerCmd(containerId).exec(); } finally { this.readWriteLock.readLock().unlock(); } }
@Override public void close() { try { try { client.stopContainerCmd(containerInfo.getId()).withTimeout(30).exec(); } catch (Exception ex) { // no-op } client.removeContainerCmd(containerInfo.getId()) .withForce(true) .withRemoveVolumes(true) .exec(); client.close(); } catch (Exception e) { // no-op } isClosed = true; }
@Override protected Void execute(StopContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/stop").resolveTemplate("id", command.getContainerId()); if (command.getTimeout() != null) { webResource = webResource.queryParam("t", String.valueOf(command.getTimeout())); } LOGGER.trace("POST: {}", webResource); webResource.request().accept(MediaType.APPLICATION_JSON).post(null); return null; } }
public void stopContainer(String id){ dockerClient.stopContainerCmd(id).exec(); }
private void stopAndRemoveContainer(String containerId) { this.dockerClient.stopContainerCmd(containerId).withTimeout(this.stopContainerTimeout).exec(); this.dockerClient.removeContainerCmd(containerId).withForce(true).exec(); }
@Override protected Void execute(StopContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/stop").resolveTemplate("id", command.getContainerId()); if (command.getTimeout() != null) { webResource = webResource.queryParam("t", String.valueOf(command.getTimeout())); } LOGGER.trace("POST: {}", webResource); webResource.request().accept(MediaType.APPLICATION_JSON).post(null).close(); return null; } }
/** * stops a {@link Container} * * @param id - id of {@link Container} */ public void stopContainer(String id) throws NotFoundException, NotModifiedException { if (isContainerRunning(id)) { dockerClient.stopContainerCmd(id).exec(); } }
protected final void doClose() { final DockerClient dockerClient = DockerClientBuilder.getInstance().build(); LOG.info("docker stop " + containerId + "..."); try { dockerClient.stopContainerCmd(containerId).withTimeout(10).exec(); } catch (final Throwable t) { LOG.info("docker kill " + containerId + "..."); try { dockerClient.killContainerCmd(containerId).exec(); } catch (final Throwable tt) { System.err.println(tt.getMessage()); } } LOG.info("docker rm " + containerId + "..."); try { dockerClient.removeContainerCmd(containerId).exec(); } catch (final Throwable t) { t.printStackTrace(System.err); } try { streamsCallback.close(); } catch (final IOException e) { e.printStackTrace(System.err); } } }
@Override protected Void execute(StopContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/stop").resolveTemplate("id", command.getContainerId()); if (command.getTimeout() != null) { webResource = webResource.queryParam("t", String.valueOf(command.getTimeout())); } LOGGER.trace("POST: {}", webResource); webResource.request().accept(MediaType.APPLICATION_JSON).post(null); return null; } }
public Void call() throws Exception { DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, null); //TODO check, if container is actually running client.stopContainerCmd(id).exec(); return null; }
if( !containerNowStopped ) { client.stopContainerCmd(containerId) .withTimeout(10) .exec(); containerNowStopped = true; logger.println("Stopped container '"+ containerId + "' " + containerDescription + ".");
@Override public void execute(Run<?, ?> build, Launcher launcher, TaskListener listener) throws DockerException { final PrintStream llog = listener.getLogger(); LOG.info("Stopping all containers"); llog.println("Stopping all containers"); for (DockerLaunchAction.Item containerItem : getLaunchAction(build).getRunning()) { LOG.info("Stopping container {}", containerItem.id); llog.println("Stopping container " + containerItem.id); containerItem.client.stopContainerCmd(containerItem.id).exec(); if (remove) { LOG.info("Removing container {}", containerItem.id); llog.println("Removing container " + containerItem.id); containerItem.client.removeContainerCmd(containerItem.id).exec(); } } }
private void executeOnDocker(Run<?, ?> build, PrintStream llog, DockerClient client) throws DockerException { try { client.stopContainerCmd(containerId).exec(); } catch (NotModifiedException ex) { LOG.info("Already stopped."); llog.println("Already stopped."); } getLaunchAction(build).stopped(client, containerId); if (remove) { LOG.info("Removing container {}...", containerId); llog.println("Removing container " + containerId + "..."); client.removeContainerCmd(containerId); } }
public void stopContainer(String containerName, boolean withRecording) { if (isRunningContainer(containerName)) { log.debug("Stopping container {}", containerName); if (withRecording) { String stopRecordingOutput = execCommand(containerName, true, "stop-video-recording.sh"); log.debug("Stopping recording in container {}:", containerName, stopRecordingOutput); try { // Wait for FFMPEG to finish writing recording file Thread.sleep(5000); } catch (InterruptedException e) { log.warn("Exception waiting for recording file", e); } if (recordingNameMap.containsKey(containerName)) { String recordingName = recordingNameMap.get(containerName); copyFileFromContainer(containerName, "/home/ubuntu/recordings/" + recordingName + ".mp4", KurentoTest.getDefaultOutputFolder().getAbsolutePath()); recordingNameMap.remove(containerName); } } getClient().stopContainerCmd(containerName).exec(); } else { log.debug("Container {} is not running", containerName); } }