【问题标题】:java.lang.AssertionError: Docker environment has more than 2GB freejava.lang.AssertionError: Docker 环境有超过 2GB 可用空间
【发布时间】:2019-03-05 14:31:41
【问题描述】:

我一直在为使用 docker 的程序创建测试。一切都运行良好,直到我在任何测试开始时突然遇到这个问题

ℹ︎ Checking the system...
    ✔ Docker version is newer than 1.6.0
    ✘ Docker environment has more than 2GB free

Test ignored.

Test ignored.

java.lang.AssertionError: Docker environment has more than 2GB free

at org.rnorth.visibleassertions.VisibleAssertions.fail(VisibleAssertions.java:437)
at org.rnorth.visibleassertions.VisibleAssertions.assertTrue(VisibleAssertions.java:129)
at org.testcontainers.DockerClientFactory.checkDiskSpace(DockerClientFactory.java:168)
at org.testcontainers.DockerClientFactory.lambda$client$1(DockerClientFactory.java:127)
at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:230)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:118)
at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:116)
at my.project.historyservice.MongoDBTest.<clinit>(MongoDBTest.java:24)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.get(Field.java:393)
at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

MongoDBTest 类以:

public class MongoDBTest
{
  @ClassRule
  public static GenericContainer mongodb = new GenericContainer("mongo:3.6")
          .withExposedPorts(27017)
          .waitingFor(Wait.forListeningPort());

第 24 行是我称之为“new GenericContainer”的地方

我无法弄清楚可能是什么问题。我的电脑有 16GB 的 RAM,其中大约 10GB 应该是空闲的。在问题出现之前,我今天成功运行了大约 10 次测试,我尝试重新启动计算机,但没有帮助。

【问题讨论】:

  • 它正在检查您的 磁盘 空间,而不是您的 RAM。
  • 谢谢!我通过从磁盘中删除一些文件解决了这个问题。
  • 在我的情况下,即使我从磁盘中删除了文件,也只有这个命令有效:docker stop $(docker ps -a -q);docker kill $(docker ps -q) ;docker rm $(docker ps -a -q);docker rmi $(docker images -q)

标签: java docker testing out-of-memory


【解决方案1】:

感谢@pafede2,docker rmi $(docker images -q) 成功了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 2013-05-17
    • 2021-09-04
    • 1970-01-01
    • 2019-09-27
    • 2013-09-27
    • 2013-01-14
    相关资源
    最近更新 更多