Search code examples
scalagarbage-collectiondockersbtboot2docker

GC overhead limit exceeded in Docker when trying to build project by sbt


I am trying to build sbt project inside docker container and receiving such error:

java.lang.OutOfMemoryError: GC overhead limit exceeded

System specs:

  • OS osx + boot2docker(8 gig RAM for virtual machine)
  • ubuntu 15.10 inside docker container
  • Oracle java 1.7 or Oracle java 1.8 or OpenJdk 1.8
  • Scala version 2.11.6
  • sbt version 0.13.8

It fails only if I am running docker build w/ Dockerfile. If I do it manually by logging to the container, it builds project w/o exception.

OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
sbt appears to be exiting abnormally.
The log file for this session is at /tmp/sbt4972348477806548245.log
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.io.UnixFileSystem.resolve(UnixFileSystem.java:108)
    at java.io.File.<init>(File.java:262)
    at java.io.File.listFiles(File.java:1290)
    at sbt.FilterFiles.handleFile(Path.scala:192)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:204)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
Error during sbt execution: java.lang.OutOfMemoryError: GC overhead limit exceeded
2015/07/15 21:59:19 The command '/bin/sh -c /web/tools/bin/sbt compile' returned a non-zero code: 1

Many thanks for any help!!1


Solution

  • The problem was in sbt setting USER someuser and then running sbt clean under this user. The solution is in running sbt clean w/ next command RUN runuser -l someuser -c 'sbt clean.


    was:

    USER someuser
    sbt clean
    

    become:

    runuser -l someuser -c 'sbt clean'