Spotify docker-maven-plugin unauthorized: authentication required public repo
Asked Answered
Z

2

8

I am having trouble pushing my docker image to the hub using the following command:

mvn clean package docker:build -DpushImage

Each time I get the following response:

[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]

When I try to login using one of the following commands, I keep getting the errors even tough the login succeeded

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

OR

docker login

I did create an empty repo on hub just to try fixing it:

enter image description here

Any ideas?

Zagreb answered 7/10, 2016 at 19:27 Comment(0)
J
11

Did you correctly configure the authentication settings?

User and password can be set in settings.xml:

<servers>
  <server>
    <id>docker-hub</id>
    <username>jdruwe</username>
    <password>secret-password</password>
    <configuration>
      <email>[email protected]</email>
    </configuration>
  </server>
</servers>

Then, the pom references these settings:

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

More detailed information can be found here: https://github.com/spotify/docker-maven-plugin#authenticating-with-private-registries

Judicator answered 7/10, 2016 at 19:40 Comment(3)
But isn't this for private registries, do I also need to do this for regular public hub?Zagreb
U're welcome. So the term 'private registry' was fairly misleading.Judicator
Indeed, I thought it was a company private repo of images :)Zagreb
K
0

The above mentioned work-around worked like magic. However, settings.xml file was missing on my machine. Created setttings.xml under /Users/username/.m2 directory on my machine as follows and it worked

<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>
Kurbash answered 24/10, 2021 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.