Gradle not finding cached dependencies offline

I’m working behind a firewall that blocks many repositories. I’m trying to run a Gradle build in a Docker image created from the .gradle directory.

Image for reference: console.cloud.google.com/gcr/images/spinnaker-marketplace/GLOBAL/gradle_cache:latest

If I run the container I can cd into /gradle_cache/.gradle and see /caches, which contains modules-2 and files-2.1 as expected. I can also find dependencies in there.

I set the GRADLE_USER_HOME env variable to /gradle_cache/.gradle and then try running ./gradlew build --offline.

The output from that is a whole list of “Could not download xxx. No cached version available for offline mode”. Which is frustrating, because I can see it in the cache.

Is there any way to debug why this is happening?