2016-11-07 182 views
1

我正嘗試將我在本地使用maven構建的docker鏡像推送到Docker Cloud/Docker Hub中的公共/私有存儲庫中。但是,索引響應在嘗試Push時沒有包含任何端點.Below是我的pom.xml的示例配置。如何解決使用Maven將Docker鏡像推送到私有存儲庫時的身份驗證問題

我不知道我錯過了哪個配置。

<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設置的配置

 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught 
    at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:130) 
    at com.spotify.docker.TagMojo.execute(TagMojo.java:44) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) 
    ... 20 more 
Caused by: com.spotify.docker.client.exceptions.DockerException: Index response didn't contain any endpoints 
    at com.spotify.docker.client.AnsiProgressHandler.progress(AnsiProgressHandler.java:52) 
    at com.spotify.docker.Utils$DigestExtractingProgressHandler.progress(Utils.java:150) 
    at com.spotify.docker.client.ProgressStream.tail(ProgressStream.java:77) 
    at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1040) 
    at com.spotify.docker.Utils.pushImage(Utils.java:83) 
    at com.spotify.docker.TagMojo.execute(TagMojo.java:119) 
    at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:128) 

回答

2

打開settings.xml並添加此服務器憑據。通常這個文件位於.m2文件夾,以便在這裏添加類似:

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

此設置不應該(和AFAIK不能定)pom.xml因爲安全問題。

如果您對更安全的選項感興趣,可以像例子here那樣加密您的密碼。


你太亂了pom.xml。嘗試從最簡單的pom.xml配置開始。檢查springio example並將springio物業更改爲您的docker hub回購。

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

我在我的setting.xml中提供了我的碼頭中心憑證。但現在在試圖推動Im獲取索引響應的最後一步中不包含任何端點異常。 – springbootlearner

+0

你在'pom.xml'中定義了什麼'registryUrl'? – VladoDemcak

+0

這是我的註冊網址https://hub.docker.com/ – springbootlearner

相關問題