Pushing Image Into Docker Hub Maven
Tag and push a Maven application image to Docker Hub.
After building a Docker image locally, you can push it to Docker Hub so another machine can pull and run it.
This is how Docker images move from your laptop to a server, teammate, or deployment pipeline.
Log in to Docker Hub
Use:
docker loginEnter your Docker Hub username and password or access token.
Build the image
Build your Maven web application image:
docker build -t maven-web-app:1.0 .Check it:
docker imagesTag the image for Docker Hub
Docker Hub images use this format:
username/repository-name:tagTag your local image:
docker tag maven-web-app:1.0 username/maven-web-app:1.0Replace username with your Docker Hub username.
Push the image
Push it:
docker push username/maven-web-app:1.0After the upload finishes, open Docker Hub and confirm the repository is visible.
Why tagging matters
The tag tells Docker where to send the image.
| Image name | Meaning |
|---|---|
maven-web-app:1.0 | Local image name |
username/maven-web-app:1.0 | Docker Hub image name |
Before pushing to Docker Hub, always tag the image with your Docker Hub username. Otherwise Docker does not know which repository should receive it.
Written By: Shiva Srivastava
How is this guide?
Last updated on
