Expose property for providing extra hosts
@@ -166,6 +166,15 @@ class DockerBuildImage extends AbstractDockerRemoteApiTask implements RegistryCr
@Optional
final Property<String> target = project.objects.property(String)
+ /**
+ * Build-time additional host list to pass to the image build in the format {@code host:ip}.
+ *
+ * @since 6.2.0
+ */
+ @Input
+ @Optional
+ final SetProperty<String> extraHosts = project.objects.setProperty(String)
+
/**
* {@inheritDoc}
*/
@@ -282,6 +291,10 @@ class DockerBuildImage extends AbstractDockerRemoteApiTask implements RegistryCr
buildImageCmd.withCacheFrom(cacheFrom.get() as Set<String>)
}
+ if (extraHosts.getOrNull()) {
+ buildImageCmd.withExtraHosts(extraHosts.get())
+ }
+
String createdImageId = buildImageCmd.exec(createCallback(nextHandler)).awaitImageId()
imageId.set(createdImageId)
imageIdFile.get().asFile.text = createdImageId
