Issue
I've been using docker build
this way:
docker build --network host -t foo/bar
But now I'm trying to make use of spring-boot:build-image
mvn spring-boot:build-image -Dspring-boot.build-image.imageName=foo/bar
but this way --network
option is not provided. Unfortunately didn't find a way how to properly provide the option.
Question: How can I provide --network
with spring-boot:build-image
(assuming I need to provide this option during build
and not during run
)?
Solution
So I found the answer. Apparently this feature is available since Spring Boot 2.6.0-M2 see: https://github.com/spring-projects/spring-boot/issues/25876 and https://github.com/spring-projects/spring-boot/releases/tag/v2.6.0-M2
Starting with this version you can try to do something like
<project>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<network>host</network>
</image>
</configuration>
</plugin>
</plugins>
</build>
</project>
Answered By - Николай Беженар