Gradle under Docker - Could not open cp_proj remapped class cache

I’m getting an error when trying to build my project using Gradle 2.13 on a docker container.

All gradle commands fail with:

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘test’.

Could not open cp_proj remapped class cache for 6f7e45oinduki44jplv0c4r9s (/var/jenkins_home/.gradle/caches/2.13/scrip
ts-remapped/build_4xwqfk0ckitkb3fdwi5uf1f5e/6f7e45oinduki44jplv0c4r9s/cp_proj57408229).
java.io.FileNotFoundException: /var/jenkins_home/.gradle/caches/2.13/scripts-remapped/build_4xwqfk0ckitkb3fdwi5uf1f
5e/6f7e45oinduki44jplv0c4r9s/cp_proj57408229/classes/build_4xwqfk0ckitkb3fdwi5uf1f5e$_run_closure1$_closure3$_closure5.c
lass (Operation not permitted)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I’ve created a Stackoverflow question at:

Sample project is at: