【问题标题】:How to pipe commands in testcontainers execInContainer metod如何在 testcontainers execInContainer 方法中传递命令
【发布时间】:2021-12-02 17:52:48
【问题描述】:

我想通过 testcontainer execInContainer 方法在 docker 上运行管道命令。我能够运行单个命令(例如execInContainer("redis-cli", "keys", "*"),但是当提供管道(例如execInContainer("redis-cli", "keys", "*", "|", "grep", "-v", "test"))时,它会读取它,因为它属于上一个命令(ERR wrong number of arguments for 'keys' command)。我想要实现的是删除来自redis的所有键,除了一个。完整的脚本如下redis-cli keys * | grep -v test | xargs redis-cli DEL。知道我该怎么做吗?

【问题讨论】:

    标签: java bash redis testcontainers


    【解决方案1】:

    我向 testcontainers 团队提出了 this issue

    看起来你可以做到:

    execInContainer("sh", "-c", "foo | bar")
    

    你能试试这个吗?它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2021-06-04
      • 1970-01-01
      • 2021-06-01
      • 2019-06-25
      • 2018-11-11
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多