I’m getting an authentication error when trying to push a Docker image to Docker Hub using Maven. Here’s what I’m running:
mvn clean compile docker:build -DpushImage
The build process fails with this error message:
[WARNING] Failed to push myuser/spring-app, retrying in 10 seconds (5/5).
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default-cli) on project spring-app: Exception caught: unauthorized: authentication required -> [Help 1]
I’ve tried logging in to Docker Hub using these commands and both work fine:
docker login -u myuser https://index.docker.io/v1/
docker login
The login is successful but I still get the authentication error when Maven tries to push. I already created the repository on Docker Hub and it’s set to public. What could be causing this issue and how can I fix it?