如何使用臂架正确码头化Maven项目

我有一个Spring Boot maven应用程序,我需要使用三角臂插件对其进行dockerize,然后发送至Azure容器注册表 注册表已设置就绪,包括用户名,密码等。 我的pom.xml看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-snAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <jib-maven-plugin.version>1.7.0</jib-maven-plugin.version>
        <docker.image.prefix>containerregistry0001968.azurecr.io</docker.image.prefix>
        <java.version>1.8</java.version>
        <username>containerregistry0001968</username>
        <password>/rG=4I26Eogai7a0/OWMKxo2x7OnHIHD</password>
        <project.artifactId>demo-springboot-docker-0001968</project.artifactId>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-servicebus-jms-spring-boot-starter</artifactId>
            <version>2.1.7</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>jib-maven-plugin</artifactId>
                <groupId>com.google.cloud.tools</groupId>
                <version>1.8.0</version>
                <configuration>
                    <from>
                        <image>suranagivinod/openjdk8:latest</image>
                    </from>
                    <to>
                        <image>demo-springboot-docker-0001968</image>
                        <auth>
                            <username>containerregistry0001968</username>
                            <password>/rG=4I26Eogai7a0/OWMKxo2x7OnHIHD</password>
                        </auth>
                    </to>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

当我运行命令“ mvn compile jib:build”时, 我得到以下输出:

[INFO] Containerizing application to demo-springboot-docker-0001968...
[WARNING] Base image 'suranagivinod/openjdk8' does not use a specific image digest - build may not be reproducible
[INFO] The base image requires auth. Trying again for suranagivinod/openjdk8...
[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io
[WARNING] 
Got output:

credentials not found in native keychain

[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry.hub.docker.com
[WARNING] 
Got output:

credentials not found in native keychain

[INFO] Executing tasks:
[INFO] [==========                    ] 31.7% complete
[INFO] > pulling base image manifest
[INFO] > building dependencies layer
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.770 s
[INFO] Finished at: 2020-01-23T16:12:25-06:00
[INFO] Final Memory: 38M/410M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.8.0:build (default-cli) on project demo: Build image failed,perhaps you should make sure your credentials for 'registry-1.docker.io/library/demo-springboot-docker-0001968' are set up correctly. See https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized for help: Unauthorized for registry-1.docker.io/library/demo-springboot-docker-0001968: 401 Unauthorized
[ERROR] {"details":"incorrect username or password"}
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors,re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions,please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

基本映像在公共docker hub仓库中。当我运行docker pull时...-我可以毫无问题地将其拉出。

如何调整此pom文件以使基本图像能够被拉出?

asddsa_asddsa 回答:如何使用臂架正确码头化Maven项目

您认为:

基本映像位于公共docker hub仓库中

Docker说:

$ docker pull uranagivinod/openjdk8:latest
Error response from daemon: pull access denied for uranagivinod/openjdk8,repository does not exist or may require 'docker login': denied: requested access to the resource is denied

首先执行docker logout,然后重试,您将发现它实际上是私人图像。

,

请注意,它是目标图像,而不是基础图像。

> make sure your credentials for 'registry-1.docker.io/library/demo-springboot-docker-0001968' are set up correctly.

还请注意,这是Docker Hub存储库。

如果我尝试使用您的用户名和密码(对于Docker Hub),

$ docker login -u containerregistry0001968 -p '/rG=4I26Eogai7a0/OWMKxo2x7OnHIHD'
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password

使用Jib时请注意相同的错误消息:

incorrect username or password

您的用户名和密码不正确。我现在将更改您的密码,因为它们已公开显示。或者只是删除这个问题。

本文链接:https://www.f2er.com/2721578.html

大家都在问