docker push

Command Name: 

docker push

Description:

docker  push Push an image or a repository to a registry

Use docker push to share your images to the Docker Hub registry or to a self-hosted one.

Below are the steps to push docker image or repository to registry:

  • Signed up for Docker Hub
  • Created your first repository
  • Built a Docker container image on your computer
  • Pushed it to Docker Hub

Syntax:

easywhatis$ docker push --help

Usage: docker push [OPTIONS] NAME[:TAG]

Push an image or a repository to a registry

Options:
      --disable-content-trust   Skip image signing (default true)
easywhatis$

Example:

 

Step 1: Sign up for Docker Hub

 

Step 2: Create your first docker repository or docker registry


Once you verify your email id it will show you create repository button



Step 3: Download and install Docker Desktop

Download and install Docker Desktop. If on Linux, download Docker Engine – Community.


 

Step 4: Use docker login to login to docker hub from docker desktop

Open the terminal and sign in to Docker Hub on your computer by running docker login.

 

Step 5: Build an image

To build an image we will require a Dockerfile which is nothing but the instructions to create our image.

 

FROM busybox
CMD echo “This is my first Docker Image.”

 Run docker build -t <your_username>/my-first-repo . to build your Docker image.

 

docker build -t easywhatis/first-repo .

 

Step 6: Test an image locally

Test your docker image locally by running docker run <your_username>/first-repo.

 

Step 7: Push an image to docker hub

Run docker push /first-repo to push your Docker image to Docker Hub.


Check the image on hub.docker.com