×
☰ See All Chapters

docker push

docker push command is used to publish the images in a public repository for public discovery and consumption. We can create a new Docker image, using a commit command and a Dockerfile, build on it, and push it to the Docker Hub.

Docker Registry and Repository

Docker repository is storage of docker registry. The registry is for registering the Docker images, whereas the repository is for storing those registered Docker images in a publicly discoverable and centralized place. A Docker Registry is a place where the Docker images can be stored in order to be publicly found, accessed, and used by the.

You can compare this with Git and GitHub.  Git is a repository and GitHub is a registry. Git repository is storage of GitHub registry. You can also host Git repository in Bitbucket, Gitlab registries.

Registry

A service responsible for hosting and distributing images. The default registry is the Docker Hub.

Examples of docker registry:

  • Docker Hub 

  • Quay 

  • Google Container Registry 

  • AWS Container Registry 

Repository

Docker repository is a collection of different docker images with same name that have different tags. Tag is alphanumeric identifier of the image within a repository.

Docker Hub Registry

  • Docker Hub is the public default registry. 

  • docker pull command will download the images form Docker Hub registry. 

  • docker push command will upload the images to Docker Hub registry. 

  • https://index.docker.io/ is the docker hub registry URL. 

  • This registry has images contributed by Docker community and third parties. You can also contribute your image to public. 

  • If any image you want download form other registry you should specify the registry URL in the pull command. Following is an example of pulling an image from a third party repository hub: 

docker pull registry.example.com/myapp

docker push

Follow the below steps to publish the docker image to docker hub.

1. In order to work with the Docker Hub, you have to register with the Docker Hub, and create an account using the link at https://hub.docker.com/account/signup  and complete the verification. After you have created your login credentials, login to your account using docker login command.

docker-push-0
 

2. Build your image and make it ready locally. We are using springbootapp image which we have created in our Docker Example Chapter.  In this example we just named our image as springbootapp. When pushing an image to Docker Hub, we must specify our Docker Hub username as part of the image name. We need to create the image using below syntax.

docker build -t username/<imagename> .

docker-push-1
 

3. Publish the image.

Syntax: docker push username/<imagename>

docker-push-2
 

Now you can check the uploaded image by login into your account from https://hub.docker.com/

docker-push-3
 

All Chapters
Author