public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
final ExecCreation execCreation;
try {
execCreation = dockerClient.execCreate(containerId, command,
DockerClient.ExecCreateParam.attachStdout(), DockerClient.ExecCreateParam.attachStderr(),
DockerClient.ExecCreateParam.attachStdin());
final LogStream output = dockerClient.execStart(execCreation.id());
logger.debug(String.format("%s %s", nodeId, Arrays.toString(command)));
if (waitForExecution) {
try {
String commandOutput = output.readFully();
logger.debug(String.format("%s %s", nodeId, commandOutput));
} catch (Exception e) {
logger.debug(nodeId + " Error while executing the output.readFully()", e);
ga.trackException(e);
}
}
} catch (DockerException | InterruptedException | NullPointerException e) {
logger.debug(nodeId + " Error while executing the command", e);
ga.trackException(e);
}
}