Skip to content

gradle/docker-gradle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Gradle Docker Image

Project Status: Active License Build status

The official Docker image for Gradle. Maintained by the Gradle team as an Official Image. Thanks to @keeganwitt for his years of stewardship.

Gradle is a fast, dependable, and adaptable open-source build automation tool with an elegant and extensible declarative build language.

Supported Tags

See all tags on Docker Hub.

Combo images

Combo images are images where two different JDK versions are made available to Gradle: the latest LTS JDK and the latest (LTS or non-LTS) JDK. Gradle runs on the LTS JDK, while toolchains can target the latest JDK.

To achieve this, the following appears in the /home/gradle/.gradle/gradle.properties file of the image:

org.gradle.java.installations.auto-detect=false
org.gradle.java.installations.auto-download=false
org.gradle.java.installations.fromEnv=JAVA_LTS_HOME,JAVA_CURRENT_HOME

Available environment variables:

  • JAVA_LTS_HOME → path to the latest LTS JDK
  • JAVA_CURRENT_HOME → path to the latest current JDK

These may point to the same path if the latest JDK is an LTS release.

Usage

Build a Gradle project

docker run --rm -u gradle \
  -v "$PWD":/home/gradle/project \
  -w /home/gradle/project \
  gradle:latest gradle <task>

Replace <task> with your desired Gradle task, e.g., build.

Reusing the Gradle User Home

To persist the Gradle User Home (including Gradle caches) between runs:

docker volume create --name gradle-cache
docker run --rm -u gradle \
  -v gradle-cache:/home/gradle/.gradle \
  -v "$PWD":/home/gradle/project \
  -w /home/gradle/project gradle:latest gradle build

Note that sharing between concurrently running containers doesn't work currently (see #851).

Currently, it is not possible to override the volume declaration of the parent. If you are using this image as a base image and want the Gradle cache to be written into the next layer, you will need to use a new user (or use the --gradle-user-home/-g argument) so that a new cache is created that isn't mounted to a volume.

License

Apache License 2.0.

© Gradle Inc. 2025