如何解决使用Maven将Docker映像推送到私有存储库时的身份验证问题

如何解决使用Maven将Docker映像推送到私有存储库时的身份验证问题,maven,docker,spring-boot-maven-plugin,Maven,Docker,Spring Boot Maven Plugin,我正在尝试将我的docker映像(在本地使用maven构建)推送到docker Cloud/docker Hub中的公共/私有存储库中。但我得到的索引响应在尝试推送时不包含任何端点。下面是我的pom.xml的示例配置 我不确定这里缺少哪种配置 <build> <plugins> <plugin> <groupId>org.springframework.boot<

我正在尝试将我的docker映像(在本地使用maven构建)推送到docker Cloud/docker Hub中的公共/私有存储库中。但我得到的索引响应在尝试推送时不包含任何端点。下面是我的pom.xml的示例配置

我不确定这里缺少哪种配置

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.11</version>
            <configuration>
                <imageName>${docker.image.prefix}/dockercloudappstation</imageName>
                <dockerDirectory>src/main/docker</dockerDirectory>
                <!-- <dockerHost>tcp://192.168.99.100:2376</dockerHost> -->
                <serverId>docker-hub</serverId>
                <!-- <registryUrl>https://hub.docker.com/</registryUrl> -->
                <resources>
                    <resource>
                        <!-- <targetPath>/</targetPath> -->
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
            <executions>
                <execution>
                  <id>build-image</id>
                  <phase>package</phase>
                  <goals>
                    <goal>build</goal>
                  </goals>
                </execution>

                <execution>
                    <id>tag-image-version</id>
                    <phase>package</phase>
                    <goals>
                        <goal>tag</goal>
                    </goals>
                    <configuration>
                        <!-- <image>${docker.image.prefix}/${project.artifactId}</image> -->
                        <image>${docker.image.prefix}/dockercloudappstation</image>
                        <newName>hub.docker.com/${docker.image.prefix}/dockercloudappstation</newName>
                        <!-- <serverId>docker-hub</serverId> -->
                        <pushImage>true</pushImage>
                    </configuration>
                </execution>
                <execution>
                    <id>tag-image-latest</id>
                    <phase>package</phase>
                    <goals>
                        <goal>tag</goal>
                    </goals>
                    <configuration>
                        <!-- <image>${docker.image.prefix}/${project.artifactId}</image> -->
                        <image>${docker.image.prefix}/dockercloudappstation</image>
                        <newName>hub.docker.com/${docker.image.prefix}/dockercloudappstation:latest</newName>
                        <pushImage>true</pushImage>
                    </configuration>
                </execution>

                <execution>
                  <id>push-image</id>
                  <phase>package</phase>
                  <goals>
                    <goal>push</goal>
                  </goals>
                  <configuration>
                  <serverId>docker-hub</serverId>
                    <!-- <imageName>${docker.image.prefix}/dockercloudappstation</imageName> -->
                  </configuration>
                </execution>

打开maven设置配置的
settings.xml
,并将您的凭据添加到服务器。通常,此文件位于
.m2
文件夹中,因此在此处添加如下内容:

<servers>
  <server>
    <id>docker-hub</id>
    <username>username</username>
    <password>password</password>
  </server>
</servers>

我已在my setting.xml中提供了docker hub凭据。但是现在在最后一步,在尝试推送Im getting Index响应时,没有包含任何端点异常。在
pom.xml
中定义了什么
registryUrl
?您尝试过
https://index.docker.io/v1/
?我还没有尝试过这个选项。但是,即使我没有明确使用这个URL,系统也会尝试在上面连接仅限URL。感谢您的指导,我已更新了工作配置。我已在配置级别移动图像、新名称配置,并将其从目标中删除。
<servers>
  <server>
    <id>docker-hub</id>
    <username>username</username>
    <password>password</password>
  </server>
</servers>
<properties>
   <docker.image.prefix>springio</docker.image.prefix>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.11</version>
            <configuration>
                <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                <dockerDirectory>src/main/docker</dockerDirectory>
                <serverId>docker-hub</serverId>
<!--  <registryUrl></registryUrl> is optional and defaults to https://index.docker.io/v1/ in the Spotify docker-client dependency. -->
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>
    </plugins>
</build>