java.lang.AssertionError:Docker 环境有超过 2GB 可用空间

Cod*_*123 4 java testing out-of-memory docker

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

\n\n
\xe2\x84\xb9\xef\xb8\x8e Checking the system...\n    \xe2\x9c\x94 Docker version is newer than 1.6.0\n    \xe2\x9c\x98 Docker environment has more than 2GB free\n\nTest ignored.\n\nTest ignored.\n\njava.lang.AssertionError: Docker environment has more than 2GB free\n\nat org.rnorth.visibleassertions.VisibleAssertions.fail(VisibleAssertions.java:437)\nat org.rnorth.visibleassertions.VisibleAssertions.assertTrue(VisibleAssertions.java:129)\nat org.testcontainers.DockerClientFactory.checkDiskSpace(DockerClientFactory.java:168)\nat org.testcontainers.DockerClientFactory.lambda$client$1(DockerClientFactory.java:127)\nat org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:230)\nat org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:118)\nat org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:116)\nat my.project.historyservice.MongoDBTest.<clinit>(MongoDBTest.java:24)\nat sun.misc.Unsafe.ensureClassInitialized(Native Method)\nat sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)\nat sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)\nat java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)\nat java.lang.reflect.Field.getFieldAccessor(Field.java:1069)\nat java.lang.reflect.Field.get(Field.java:393)\nat org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)\nat org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)\nat org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)\nat org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)\nat org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)\nat org.junit.runners.ParentRunner.run(ParentRunner.java:362)\nat org.junit.runner.JUnitCore.run(JUnitCore.java:137)\nat com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)\nat com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)\nat com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)\nat com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)\n
Run Code Online (Sandbox Code Playgroud)\n\n

MongoDBTest 类以以下内容开头:

\n\n
public class MongoDBTest\n{\n  @ClassRule\n  public static GenericContainer mongodb = new GenericContainer("mongo:3.6")\n          .withExposedPorts(27017)\n          .waitingFor(Wait.forListeningPort());\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n

我不知道可能是什么问题。我的电脑有 16GB RAM,其中大约 10GB 应该是可用的。我今天成功测试了大约10次,然后才出现问题,并且我尝试过重新启动计算机,但没有帮助。

\n

Ans*_*ran 5

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