Spotify docker-maven-plugin unauthorized: authentication required public repo

Jdruwe picture Jdruwe · Oct 7, 2016 · Viewed 7k times · Source

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?

Answer

gtonic picture gtonic · Oct 7, 2016

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