.withAttachStdout(true) .withAttachStderr(true) .withTty(false) .withCmd("java", "-jar", remoteFs + '/' + remoting.getName(), "-noReconnect", "-noKeepAlive", "-slaveLog", remoteFs + "/agent.log"); if (StringUtils.isNotBlank(user)) {
public String execCommand(String containerId, boolean awaitCompletion, String... command) { ExecCreateCmdResponse exec = client.execCreateCmd(containerId).withCmd(command).withTty(false) .withAttachStdin(true).withAttachStdout(true).withAttachStderr(true).exec(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); String output = null; try { ExecStartResultCallback resultCallback = client.execStartCmd(exec.getId()).withDetach(false) .withTty(true).exec(new ExecStartResultCallback(outputStream, System.err)); if (awaitCompletion) { resultCallback.awaitCompletion(); } output = new String(outputStream.toByteArray()); } catch (InterruptedException e) { log.warn("Exception executing command {} on container {}", Arrays.toString(command), containerId, e); } return output; }
public String execCommand(String containerId, boolean awaitCompletion, String... command) { ExecCreateCmdResponse exec = client.execCreateCmd(containerId).withCmd(command).withTty(false) .withAttachStdin(true).withAttachStdout(true).withAttachStderr(true).exec(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); String output = null; try { ExecStartResultCallback resultCallback = client.execStartCmd(exec.getId()).withDetach(false) .withTty(true).exec(new ExecStartResultCallback(outputStream, System.err)); if (awaitCompletion) { resultCallback.awaitCompletion(); } output = new String(outputStream.toByteArray()); } catch (InterruptedException e) { log.warn("Exception executing command {} on container {}", Arrays.toString(command), containerId, e); } return output; }
private String execCreate(String containerId, String... commands) { ExecCreateCmdResponse execCreateCmdResponse = this.dockerClient.execCreateCmd(containerId) .withAttachStdout(true).withAttachStdin(true).withAttachStderr(true).withTty(false).withCmd(commands) .exec(); return execCreateCmdResponse.getId(); }
private String execCreate(String containerId, String... commands) { ExecCreateCmdResponse execCreateCmdResponse = this.dockerClient.execCreateCmd(containerId) .withAttachStdout(true).withAttachStdin(true).withAttachStderr(true).withTty(false).withCmd(commands) .exec(); return execCreateCmdResponse.getId(); }
private String execCreate(String containerId, String... command) { return this.client.execCreateCmd(containerId) .withAttachStdout(true).withAttachStderr(true) .withAttachStdin(true).withTty(false) .withCmd(command).exec().getId(); } }
.withAttachStdout(true) .withAttachStderr(true) .withTty(true) .withCmd("sh", "-c", "" + "echo 1 > /proc/sys/net/ipv4/ip_forward && " +
@Test public void container_should_have_static_ip_for_app_net_network() throws InterruptedException, IOException { final InspectContainerResponse pingpong = dockerClient.inspectContainerCmd("pingpong").exec(); ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(pingpong.getId()) .withAttachStdout(true).withAttachStdin(true).withAttachStderr(true).withTty(false).withCmd("ifconfig") .exec(); try (OutputStream outputStream = new ByteArrayOutputStream(); OutputStream errorStream = new ByteArrayOutputStream()) { dockerClient.execStartCmd(execCreateCmdResponse.getId()).withDetach(false) .exec(new ExecStartResultCallback(outputStream, errorStream)).awaitCompletion(); assertThat(outputStream.toString()).contains("inet addr:172.16.238.10", "inet6 addr: fe80::42:acff:fe10:ee0a/64"); } }
execCreateCmd.withTty(tty);