Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ The following table shows the environment variables and their values:
|===
| Environment variable | Description

| DOCKER_HOST
| DOCKER_HOST
| URL containing the host and port for the Docker daemon - e.g. `tcp://192.168.99.100:2376`

| DOCKER_TLS_VERIFY
| DOCKER_TLS_VERIFY
| Enable secure HTTPS protocol when set to `1` (optional)

| DOCKER_CERT_PATH
| DOCKER_CERT_PATH
| Path to certificate and key files for HTTPS (required if `DOCKER_TLS_VERIFY=1`, ignored otherwise)
|===

Expand Down Expand Up @@ -59,7 +59,7 @@ The following table summarizes the available properties and their default values
| `imageName`
| `--imageName`
| {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[Image name] for the generated image.
| `docker.io/library/${project.artifactId}:${project.version}`
| `docker.io/library/${project.name}:${project.version}`

| `environment`
|
Expand Down Expand Up @@ -148,7 +148,7 @@ include::../gradle/packaging/boot-build-image-env-proxy.gradle.kts[tags=env]

[[build-image-example-custom-image-name]]
==== Custom Image Name
By default, the image name is inferred from the `artifactId` and the `version` of the project, something like `docker.io/library/${project.artifactId}:${project.version}`.
By default, the image name is inferred from the `name` and the `version` of the project, something like `docker.io/library/${project.name}:${project.version}`.
You can take control over the name by setting task properties, as shown in the following example:

[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
mainClassName 'com.example.ExampleApplication'
}

// tag::image-name[]
bootBuildImage {
imageName = "example.com/library/${project.artifactId}"
imageName = "example.com/library/${project.name}"
}
// end::image-name[]

task bootBuildImageName {
doFirst {
println(tasks.bootBuildImage.imageName)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import org.springframework.boot.gradle.tasks.bundling.BootJar
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage

plugins {
java
id("org.springframework.boot") version "{gradle-project-version}"
}

tasks.getByName<BootJar>("bootJar") {
mainClassName = "com.example.ExampleApplication"
}

// tag::image-name[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
imageName = "example.com/library/${project.artifactId}"
imageName = "example.com/library/${project.name}"
}
// end::image-name[]

tasks.register("bootBuildImageName") {
doFirst {
println(tasks.getByName<BootBuildImage>("bootBuildImage").imageName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ void bootBuildImageWithCustomProxySettings() throws IOException {
.contains("HTTPS_PROXY=https://proxy.example.com");
}

@TestTemplate
void bootBuildImageWithCustomImageName() throws IOException {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-name")
.build("bootBuildImageName");
assertThat(result.getOutput()).contains("example.com/library/" + this.gradleBuild.getProjectDir().getName());
}

protected void jarFile(File file) throws IOException {
try (JarOutputStream jar = new JarOutputStream(new FileOutputStream(file))) {
jar.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
Expand Down