com.palantir.docker.compose.DockerComposeRule.exec()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中com.palantir.docker.compose.DockerComposeRule.exec()方法的一些代码示例,展示了DockerComposeRule.exec()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DockerComposeRule.exec()方法的具体详情如下:
包路径:com.palantir.docker.compose.DockerComposeRule
类名称:DockerComposeRule
方法名:exec

DockerComposeRule.exec介绍

暂无

代码示例

代码示例来源:origin: palantir/atlasdb

private String dockerExecOnClient(String... arguments) {
    for (int i = 1; i <= MAX_EXEC_TRIES; i++) {
      try {
        log.info("Attempting docker-exec with arguments: {}", Arrays.asList(arguments));
        return dockerComposeRule.exec(
            DockerComposeExecOption.noOptions(),
            CONTAINER,
            ImmutableDockerComposeExecArgument.arguments(arguments));
      } catch (InterruptedException | IOException e) {
        throw Throwables.propagate(e);
      } catch (DockerExecutionException e) {
        if (i != MAX_EXEC_TRIES) {
          // I have seen very odd flakes where exec terminates with exit code 129
          // i.e. they are interrupted with the hangup signal.
          log.warn("Encountered error in docker-exec, retrying (attempt {} of {})", i, MAX_EXEC_TRIES, e);
        } else {
          log.error("Made {} attempts, and now giving up", MAX_EXEC_TRIES, e);
          throw e;
        }
      }
    }
    throw new IllegalStateException(
        String.format("Unexpected state after %s unsuccessful attempts in docker-exec", MAX_EXEC_TRIES));
  }
}

代码示例来源:origin: palantir/atlasdb

public static String execCliCommand(String client, String command) throws IOException, InterruptedException {
  return docker.exec(
      DockerComposeExecOption.noOptions(),
      client,
      DockerComposeExecArgument.arguments("bash", "-c", command));
}

代码示例来源:origin: com.palantir.docker.compose/docker-compose-rule

public String exec(DockerComposeExecOption options, String containerName, DockerComposeExecArgument arguments)
    throws IOException, InterruptedException {
  return rule.exec(options, containerName, arguments);
}

代码示例来源:origin: palantir/docker-compose-rule

@Ignore // This test will not run on Circle CI because it does not currently support docker-compose exec.
@Test
public void exec_returns_output() throws Exception {
  assertThat(docker.exec(options(), CONTAINERS.get(0), arguments("echo", "hello")), is("hello"));
}

相关文章