SBT is failing with OutOfMemory in recent circleci/openjdk:8* images when building a Docker image locally

Using a even minimal docker file:

FROM circleci/openjdk:8u181-jdk
RUN sbt sbtVersion

and

docker build .

In a directory containing only the Dockerfile, I get a java.lang.OutOfMemoryError: GC overhead limit exceeded

This also happens with more complicated Dockerfiles, the example above was just the smallest example in which I could reproduce the problem when diagnosing.

I’ve tried several tagged versions starting circleci/openjdk:8 - all have failed with the same error

Unless you have changed it, you will be limited to 4G of RAM in the Docker Executor. However, if you are on a paid tier, you can request larger limits.

If you are on the free tier, you can switch to a Machine Executor, which will give you a 8G limit, and presently this option is free of charge. You can either use the bare VM as-is, or install Docker yourself and proceed as per the Docker Executor.

This is fascinating… except… I’m not running in the executor.
I’m simply running a docker build on my local machine using one of the images supplied by circleci

Ah, righto - that puts a very different slant on it. In general, Docker will expand its memory to as much as it needs, limited either by specified limits or by memory available on the host. Since you do not have any limits set (in the build command), it might be that you do not have enough memory free to complete the operation.

Alternatively, perhaps there is a GC setting you can change. I would suggest searching Stack Overflow for the error (plus the word “Docker” maybe) to see how other folks have tackled it.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.