【问题标题】:Container not starting with GenericContainer容器不以 GenericContainer 开头
【发布时间】:2020-05-28 16:39:35
【问题描述】:

我刚刚开始使用测试容器,我遇到了一些问题。以下是我的代码:

 @ClassRule
    public static GenericContainer redisContainer =
            new GenericContainer("corporateurl/redis:latest")
                   .withExposedPorts(6379);

当我在没有暴露端口的情况下运行它时,它可以正常工作,但使用暴露端口它会给出错误:

Could not start container
java.lang.IllegalStateException: Container did not start correctly.

知道如何防止这种情况发生吗?

【问题讨论】:

    标签: testcontainers


    【解决方案1】:

    真的很难说,因为异常没有提供任何线索,我建议你尝试访问日志: https://www.testcontainers.org/features/container_logs/

    在您开始测试时,本地主机上是否有 6379,是否有其他容器?

    【讨论】:

      猜你喜欢
      • 2016-07-10
      • 2019-06-27
      • 2019-11-25
      • 1970-01-01
      • 2021-08-28
      • 2019-07-13
      • 2017-06-05
      • 1970-01-01
      • 2016-12-28
      相关资源
      最近更新 更多