Spring Boot 2.3构建映像失败

时间:2020-05-16 08:02:36

标签: spring-boot docker maven

我将{{3}}更新为Spring Boot 2.3.0.RELEASE,并尝试直接从"TEST THING WOW"目标构建映像,但是失败了。

此示例的我的工作环境。

  • Windows 10和最新的Docker桌面
  • Java 11(采用OpenJDK 11)
spring-boot:build-image

当我在项目根文件夹中运行命令时。

# docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

#java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)
mvn clean spring-boot:build-image -DskipTests

在运行此命令之前,我尝试设置一个[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:build-image (default-cli) on project angular-spring-reactive-sample-server: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:build-image failed: Docker API call to 'localhost/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3' failed with status code 500 "Internal Server Error" -> 环境,失败了。

HTTP_PROXY添加到命令中,并获得如下日志。

-e

2 个答案:

答案 0 :(得分:1)

使用Spring Boot 2.3在Ubuntu和中国构建映像的步骤:

  • 首先检查docker是否已正确安装(通过运行sudo apt install docker.io,将当前用户添加到docker组中)
  • 从github下载灯笼
  • 通过键入lantern &在终端中启动灯笼
  • 从start.spring.io中,选择gradle,spring boot 2.3,webflux或您需要的任何内容,然后下载zip
  • 解压缩文件
  • 在浏览器中打开灯笼(我使用chrome),通过设置检查代理信息
  • 将代理添加到$project/gradle/wrapper下的gradle-wrapper.properties

    systemProp.proxySet = true systemProp.https.proxyHost = 127.0.0.1 systemProp.https.proxyPort = 45587 systemProp.http.proxyHost = 127.0.0.1 systemProp.http.proxyPort = 45587

  • sudo vim /lib/systemd/system/docker.service,然后在[service]部分中添加以下行:

    EnvironmentFile = / etc / default / docker

  • 使用灯笼设置编辑/etc/default/docker文件:

    ALL_PROXY = socks5://127.0.0.1:37267

  • docker pull gcr.io/paketo-buildpacks/builder:base-platform-api-0.3

  • docker pull gcr.io/paketo-buildpacks/run:base-cnb
  • 然后,它应该在./gradlew bootBuildImage上工作

当Lantern不稳定时,请重试docker pull或gradlew,它可以继续/重试下载...

当github被阻止时,假定172.17.0.1是docker0接口的ip,将以下内容添加到build.gradle中:

bootBuildImage {
    environment = [
        "HTTP_PROXY" : "http://172.17.0.1:45587",
        "http_proxy" : "http://172.17.0.1:45587",
        "HTTPS_PROXY": "http://172.17.0.1:45587",
        "https_proxy": "http://172.17.0.1:45587"                
    ]
}

答案 1 :(得分:0)

有一些问题。但是我切换到spring-boot-starter-parent 2.4.1后就解决了

<parent>
<groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.4.1</version>
   <relativePath/> <!-- lookup parent from repository -->
</parent>