Now we are going to cover how to publish our Docker images onto Docker Hub.
Visit:
https://hub.docker.comSign up for an account.
After signing up:
Just as on GitHub we create repositories to push our code, similarly on Docker Hub we create repositories for Docker images.
Create a new repository:
test-application)Once the repository is created, build your image using the exact Docker Hub repository naming format:
docker build -t your-username/test-application .docker loginThen enter:
when prompted.
docker loginDocker will:
docker push your-username/test-applicationRefresh your Docker Hub repository page.
By default:
latest tag is usedYou will see:
latest)docker pull your-username/test-applicationJust like we pull Docker images created by others, now others can pull our image too.
We can even delete our local project:
And still recover everything anytime using:
docker pull your-username/test-application
docker run your-username/test-applicationThe application is no longer tied to your machine — it is packaged as a Docker image.
This means:
docker build creates an image with your usernamedocker login authenticates your Docker Hub accountdocker push uploads your image to Docker Hub