use of com.github.dockerjava.api.command.ExecCreateCmdResponse in project druid by druid-io.
the class DruidClusterAdminClient method runCommandInDockerContainer.
public Pair<String, String> runCommandInDockerContainer(String serviceName, String... cmd) throws Exception {
DockerClient dockerClient = newClient();
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(findDockerContainer(dockerClient, serviceName)).withAttachStderr(true).withAttachStdout(true).withCmd(cmd).exec();
dockerClient.execStartCmd(execCreateCmdResponse.getId()).exec(new ExecStartResultCallback(stdout, stderr)).awaitCompletion();
return new Pair<>(stdout.toString(StandardCharsets.UTF_8.name()), stderr.toString(StandardCharsets.UTF_8.name()));
}
Aggregations