How to Push Docker Image to Docker Hub

This is a quick guide on how to push Docker images to Docker Hub.

Prerequisites

Pushing Image to Docker Hub

First login to Docker Hub using your username and password when prompted

docker login -u <username>

Build your Docker image

docker -t organization/repo:tag .

In this guide the command is

docker -t devguides/hello-world:latest .

Push image to Docker Hub

docker push devguides/hello-world:latest

Add Additional Tags to Your Docker Image

You often want to include tags like version in addition to the latest tag. To add a version tag you write the following commands:

docker tag devguides/hello-world:latest devguides/hello-world:1.0.0
docker push devguides/hello-world:1.0.0

The commands above will create a version tag called 1.0.0 and push the tag to Docker Hub.

This example project can be found at Docker Hub