【问题标题】:Spotify docker-maven-plugin unauthorized: authentication required public repoSpotify docker-maven-plugin 未经授权:需要身份验证的公共回购
【发布时间】:2017-02-16 21:11:51
【问题描述】:

我无法使用以下命令将我的 docker 映像推送到集线器:

mvn clean package docker:build -DpushImage

每次我收到以下回复:

[WARNING] Failed to push jdruwe/k8s-product-owner, retrying in 10 seconds (5/5).

...

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default-cli) on project k8s-product-owner: Exception caught: unauthorized: authentication required -> [Help 1]

当我尝试使用以下命令之一登录时,即使登录成功,我也会不断收到错误

docker login -u jdruwe https://index.docker.io/v1/

OR

docker login

我确实在集线器上创建了一个空仓库,只是为了尝试修复它:

有什么想法吗?

【问题讨论】:

    标签: maven docker maven-plugin spotify docker-registry


    【解决方案1】:

    您是否正确配置了身份验证设置?

    用户和密码可以在settings.xml中设置:

    <servers>
      <server>
        <id>docker-hub</id>
        <username>jdruwe</username>
        <password>secret-password</password>
        <configuration>
          <email>foo@foo.bar</email>
        </configuration>
      </server>
    </servers>
    

    然后,pom 引用这些设置:

     <plugin>
      <groupId>com.spotify</groupId>
      <artifactId>docker-maven-plugin</artifactId>
      <version>VERSION GOES HERE</version>
      <configuration>
        [...]
        <serverId>docker-hub</serverId>
        <registryUrl>https://index.docker.io/v1/</registryUrl>
      </configuration>
    </plugin>
    

    更多详细信息可以在这里找到:https://github.com/spotify/docker-maven-plugin#authenticating-with-private-registries

    【讨论】:

    • 但这不是用于私人注册中心吗,我是否也需要为常规公共中心这样做?
    • 不客气。所以“私人注册中心”这个词相当具有误导性。
    • 确实,我还以为是公司的私人图片仓库 :)
    【解决方案2】:

    上面提到的解决方法就像魔术一样。但是,我的机器上缺少 settings.xml 文件。在我的机器上的 /Users/username/.m2 目录下创建了 setttings.xml,如下所示,它起作用了

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <servers>
            <server>
                <id>docker.io</id>
                <username>your_username</username>
                <password>your_password</password>
            </server>
        </servers>
    </settings>
    

    【讨论】:

      猜你喜欢
      • 2017-07-17
      • 2018-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-17
      • 2018-06-13
      相关资源
      最近更新 更多