【问题标题】:specify "--network=host" using spring-boot:build-image使用 spring-boot:build-image 指定“--network=host”
【发布时间】:2021-10-29 05:29:43
【问题描述】:

我一直这样使用docker builddocker build --network host -t foo/bar

但现在我正在尝试使用spring-boot:build-image

mvn spring-boot:build-image -Dspring-boot.build-image.imageName=foo/bar

但是这种方式没有提供--network 选项。不幸的是,没有找到正确提供选项的方法。

问题:如何为--network 提供spring-boot:build-image(假设我需要在build 期间而不是在run 期间提供此选项)?

【问题讨论】:

  • 为什么需要禁用 Docker 的网络堆栈,尤其是在构建过程中?
  • @DavidMaze 这些是要求¯_(ツ)_/¯

标签: java spring-boot docker maven spring-boot-maven-plugin


【解决方案1】:

所以我找到了答案。显然,此功能 自 Spring Boot 2.6.0-M2 起可用 看: https://github.com/spring-projects/spring-boot/issues/25876https://github.com/spring-projects/spring-boot/releases/tag/v2.6.0-M2

从这个版本开始,你可以尝试做类似的事情

<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>

【讨论】:

    猜你喜欢
    • 2023-01-28
    • 2021-05-15
    • 2020-10-01
    • 2021-10-13
    • 2021-03-31
    • 2021-01-10
    • 2022-06-17
    • 1970-01-01
    • 2021-12-04
    相关资源
    最近更新 更多