Jib maven 插件无法将图像从本地推送到 Docker Hub
Jib maven plugn is not able to push image from local to DockerHub
我有简单的 Spring 启动应用程序。我尝试使用 jib-maven 插件创建它的 docker 图像。但是,当我构建此应用程序时,它因 401 Unauthorized 异常而失败。但是我在日志中正确地提供了所有配置我可以看到它被正确读取但是在推送它失败时出现 I/O 图像错误..
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<from>
<image>openjdk:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</from>
<to>
<image><userName>/java-spring/${project.artifactId}:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-Xmx512m</jvmFlag>
</jvmFlags>
</container>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
我在构建时使用 mvn clean install -Djib.httpTimeout=0 -X
[DEBUG] bearer auth succeeded for registry-1.docker.io/<userName>/java-spring/singin
[DEBUG] TIMED Authenticating push to registry-1.docker.io : 3433.0 ms
[DEBUG] TIMING Preparing layer pushers
[DEBUG] TIMED Preparing layer pushers : 2.0 ms
[DEBUG] TIMING Pushing BLOB digest: sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f, size: 1544
[DEBUG] TIMING Pushing BLOB digest: sha256:fe3d76ed81f8e2c7419641c7accf6a0f1c4d15a5b5e344d5848422d7e481edd2, size: 314
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pulling base image manifest : 4079.0 ms
[DEBUG] TIMING Preparing base image layer pullers
[DEBUG] TIMED Preparing base image layer pullers : 0.0 ms
[DEBUG] TIMING Preparing layer pushers
[DEBUG] TIMED Preparing layer pushers : 1.0 ms
[DEBUG] TIMING Pulling base image layer sha256:69e2f037cdb30c8d329b17dad42cd9d92a45d93c17e6699650b23c55eceacb5f
[DEBUG] TIMING Pulling base image layer sha256:42196c7f3671dd040a08f3515d758e322ed3276abedebd86072bb966f068a783
[DEBUG] TIMING Pulling base image layer sha256:3e010093287c245d72a774033b4cddd6451a820bfbb1948c97798e1838858dd2
[DEBUG] TIMING Pulling base image layer sha256:d0e5d6aa3b5285b5d96315f094cdf61ee0c54fbbf9c2e559a09a85afcdc65336
[DEBUG] TIMING Pulling base image layer sha256:423773833537fe0e40fa349a4bc0a2001340dac0c77d7a9fcf693df3068d4a3d
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pushing BLOB digest: sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f, size: 1544 : 2713.0 ms
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pushing BLOB digest: sha256:fe3d76ed81f8e2c7419641c7accf6a0f1c4d15a5b5e344d5848422d7e481edd2, size: 314 : 2853.0 ms
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] Building dependencies layer built sha256:e33c10e34799462008afa4ef873291b337878a958002e7567db5bbefa9602633
[DEBUG] TIMED Building dependencies layer : 6513.0 ms
[DEBUG] TIMING Pushing BLOB digest: sha256:e33c10e34799462008afa4ef873291b337878a958002e7567db5bbefa9602633, size: 16212760
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pulling base image layer sha256:69e2f037cdb30c8d329b17dad42cd9d92a45d93c17e6699650b23c55eceacb5f : 2622.0 ms
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pulling base image layer sha256:42196c7f3671dd040a08f3515d758e322ed3276abedebd86072bb966f068a783 : 2660.0 ms
[DEBUG] TIMED Building and pushing image : 7058.0 ms
[ERROR] I/O error for image [registry-1.docker.io/<userName>/java-spring/singin]:
[DEBUG] TIMED Pulling base image layer sha256:423773833537fe0e40fa349a4bc0a2001340dac0c77d7a9fcf693df3068d4a3d : 2707.0 ms
[ERROR] java.net.SocketException
[ERROR] Socket closed
[DEBUG] TIMED Pulling base image layer sha256:3e010093287c245d72a774033b4cddd6451a820bfbb1948c97798e1838858dd2 : 2726.0 ms
[DEBUG] TIMED Pushing BLOB digest: sha256:e33c10e34799462008afa4ef873291b337878a958002e7567db5bbefa9602633, size: 16212760 : 390.0 ms
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
详细日志
[DEBUG] refreshing bearer auth token for registry-1.docker.io/userName/java-spring/singin/singin...
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:userName/java-spring/singin/singin:pull,push&scope=repository:library/openjdk:pull
Accept: */*
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -H 'Accept: */*' -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)' -- 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:userName/java-spring/singin/singin:pull,push&scope=repository:library/openjdk:pull'
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 31 Jul 2020 19:00:59 GMT
Transfer-Encoding: chunked
Strict-Transport-Security: max-age=31536000
Jul 31, 2020 3:00:58 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 4,279 bytes
Jul 31, 2020 3:00:58 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"token":"eyJhbGciOiJ...","access_token":"eyJhbGciOiJ...","expires_in":300,"issued_at":"2020-07-31T19:00:59.184599872Z"}
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
HEAD https://registry-1.docker.io/v2/userName/java-spring/singin/singin/blobs/sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f
Accept:
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X HEAD -H 'Accept: ' -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)' -- 'https://registry-1.docker.io/v2/userName/java-spring/singin/singin/blobs/sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f'
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:userName/java-spring/singin/singin:pull",error="insufficient_scope"
Date: Fri, 31 Jul 2020 19:00:59 GMT
Content-Length: 179
Strict-Transport-Security: max-age=31536000
更新
我在配置图像时出错 URL。我在我的 DockerHub 中手动创建了一个 repo 作为 java-spring 并将其附加到图像 URL 中,它将成为Docker 不支持的多级回购。从配置和 DockerHub(删除手动创建的 repo java-spring)中删除 repo 名称后,我可以使用 JIB 从本地推送图像。
以下配置可以正常工作。
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<from>
<image>openjdk:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</from>
<to>
<image><userName>/${project.artifactId}:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-Xmx512m</jvmFlag>
</jvmFlags>
</container>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
Docker 枢纽 does not support multi-level repository names。例如,您不能在 Docker Hub 上使用 <account>/level-1/level-2/...
这样的存储库名称。因此,将 <to><image>
设置为 java-spring-${project.artifactId}:latest
(注意 java-spring
之后的 -
)应该可以解决问题。
发生这种情况时,Jib 团队 will work on showing a better error message 与 Docker Hub。
P.S。您可以删除 <from><auth>
块,因为 openjdk
是 Docker Hub 上的 public 图片。
我有简单的 Spring 启动应用程序。我尝试使用 jib-maven 插件创建它的 docker 图像。但是,当我构建此应用程序时,它因 401 Unauthorized 异常而失败。但是我在日志中正确地提供了所有配置我可以看到它被正确读取但是在推送它失败时出现 I/O 图像错误..
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<from>
<image>openjdk:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</from>
<to>
<image><userName>/java-spring/${project.artifactId}:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-Xmx512m</jvmFlag>
</jvmFlags>
</container>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
我在构建时使用 mvn clean install -Djib.httpTimeout=0 -X
[DEBUG] bearer auth succeeded for registry-1.docker.io/<userName>/java-spring/singin
[DEBUG] TIMED Authenticating push to registry-1.docker.io : 3433.0 ms
[DEBUG] TIMING Preparing layer pushers
[DEBUG] TIMED Preparing layer pushers : 2.0 ms
[DEBUG] TIMING Pushing BLOB digest: sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f, size: 1544
[DEBUG] TIMING Pushing BLOB digest: sha256:fe3d76ed81f8e2c7419641c7accf6a0f1c4d15a5b5e344d5848422d7e481edd2, size: 314
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pulling base image manifest : 4079.0 ms
[DEBUG] TIMING Preparing base image layer pullers
[DEBUG] TIMED Preparing base image layer pullers : 0.0 ms
[DEBUG] TIMING Preparing layer pushers
[DEBUG] TIMED Preparing layer pushers : 1.0 ms
[DEBUG] TIMING Pulling base image layer sha256:69e2f037cdb30c8d329b17dad42cd9d92a45d93c17e6699650b23c55eceacb5f
[DEBUG] TIMING Pulling base image layer sha256:42196c7f3671dd040a08f3515d758e322ed3276abedebd86072bb966f068a783
[DEBUG] TIMING Pulling base image layer sha256:3e010093287c245d72a774033b4cddd6451a820bfbb1948c97798e1838858dd2
[DEBUG] TIMING Pulling base image layer sha256:d0e5d6aa3b5285b5d96315f094cdf61ee0c54fbbf9c2e559a09a85afcdc65336
[DEBUG] TIMING Pulling base image layer sha256:423773833537fe0e40fa349a4bc0a2001340dac0c77d7a9fcf693df3068d4a3d
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pushing BLOB digest: sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f, size: 1544 : 2713.0 ms
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pushing BLOB digest: sha256:fe3d76ed81f8e2c7419641c7accf6a0f1c4d15a5b5e344d5848422d7e481edd2, size: 314 : 2853.0 ms
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] Building dependencies layer built sha256:e33c10e34799462008afa4ef873291b337878a958002e7567db5bbefa9602633
[DEBUG] TIMED Building dependencies layer : 6513.0 ms
[DEBUG] TIMING Pushing BLOB digest: sha256:e33c10e34799462008afa4ef873291b337878a958002e7567db5bbefa9602633, size: 16212760
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pulling base image layer sha256:69e2f037cdb30c8d329b17dad42cd9d92a45d93c17e6699650b23c55eceacb5f : 2622.0 ms
[DEBUG] refreshing bearer auth token for registry-1.docker.io/<userName>/java-spring/singin...
[DEBUG] TIMED Pulling base image layer sha256:42196c7f3671dd040a08f3515d758e322ed3276abedebd86072bb966f068a783 : 2660.0 ms
[DEBUG] TIMED Building and pushing image : 7058.0 ms
[ERROR] I/O error for image [registry-1.docker.io/<userName>/java-spring/singin]:
[DEBUG] TIMED Pulling base image layer sha256:423773833537fe0e40fa349a4bc0a2001340dac0c77d7a9fcf693df3068d4a3d : 2707.0 ms
[ERROR] java.net.SocketException
[ERROR] Socket closed
[DEBUG] TIMED Pulling base image layer sha256:3e010093287c245d72a774033b4cddd6451a820bfbb1948c97798e1838858dd2 : 2726.0 ms
[DEBUG] TIMED Pushing BLOB digest: sha256:e33c10e34799462008afa4ef873291b337878a958002e7567db5bbefa9602633, size: 16212760 : 390.0 ms
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
详细日志
[DEBUG] refreshing bearer auth token for registry-1.docker.io/userName/java-spring/singin/singin...
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:userName/java-spring/singin/singin:pull,push&scope=repository:library/openjdk:pull
Accept: */*
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -H 'Accept: */*' -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)' -- 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:userName/java-spring/singin/singin:pull,push&scope=repository:library/openjdk:pull'
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 31 Jul 2020 19:00:59 GMT
Transfer-Encoding: chunked
Strict-Transport-Security: max-age=31536000
Jul 31, 2020 3:00:58 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 4,279 bytes
Jul 31, 2020 3:00:58 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"token":"eyJhbGciOiJ...","access_token":"eyJhbGciOiJ...","expires_in":300,"issued_at":"2020-07-31T19:00:59.184599872Z"}
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
HEAD https://registry-1.docker.io/v2/userName/java-spring/singin/singin/blobs/sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f
Accept:
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X HEAD -H 'Accept: ' -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: jib 2.4.0 jib-maven-plugin Google-HTTP-Java-Client/1.34.0 (gzip)' -- 'https://registry-1.docker.io/v2/userName/java-spring/singin/singin/blobs/sha256:6a1d32d7f6ff4a41815f4be581691138a588a3e8b4faa839e1e80f7e51b2cd6f'
Jul 31, 2020 3:00:58 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:userName/java-spring/singin/singin:pull",error="insufficient_scope"
Date: Fri, 31 Jul 2020 19:00:59 GMT
Content-Length: 179
Strict-Transport-Security: max-age=31536000
更新
我在配置图像时出错 URL。我在我的 DockerHub 中手动创建了一个 repo 作为 java-spring 并将其附加到图像 URL 中,它将成为Docker 不支持的多级回购。从配置和 DockerHub(删除手动创建的 repo java-spring)中删除 repo 名称后,我可以使用 JIB 从本地推送图像。
以下配置可以正常工作。
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<from>
<image>openjdk:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</from>
<to>
<image><userName>/${project.artifactId}:latest</image>
<auth>
<username>userName</username>
<password>password</password>
</auth>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-Xmx512m</jvmFlag>
</jvmFlags>
</container>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
Docker 枢纽 does not support multi-level repository names。例如,您不能在 Docker Hub 上使用 <account>/level-1/level-2/...
这样的存储库名称。因此,将 <to><image>
设置为 java-spring-${project.artifactId}:latest
(注意 java-spring
之后的 -
)应该可以解决问题。
发生这种情况时,Jib 团队 will work on showing a better error message 与 Docker Hub。
P.S。您可以删除 <from><auth>
块,因为 openjdk
是 Docker Hub 上的 public 图片。