我一直在为我的使用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的内存,其中大约10GB应该是免费的。我运行了大约10次测试成功,今天的问题出现之前,我已经尝试重新启动电脑,但它没有帮助。
2条答案
按热度按时间4bbkushb1#
docker rmi $(docker images -q)
的成功要归功于@pafede2rdrgkggo2#
有时卷数据是罪魁祸首(至少对我来说是这样)。
删除未使用的卷和悬挂图像数据可以释放大量空间。
尝试运行
docker system prune --volumes
此命令可删除:
在我的例子中,它释放了接近32GB的磁盘空间
希望这能帮上忙