Build and push docker image to docker hub

In this blog , We will see how can we build app using docker image and push docker image to docker hub repository.

1- Install docker for windows or mac.
2- Verify your .net and docker version. If you haven’t installed docker you can download from here.
3- Pull .net images from docker registry.

Step-1 Verify docker version using below cmd.

docker version

Step-2 Verify dotnet version

dotnet --info

Step-3 Create Sample application using dotnet

dotnet new sln --name dockerdemo
dotnet new mvc --output dotnetdemodocker

Step-4 Build project using below cmd

dotnet build

Step-5 run app using below cmd.

dotnet run

Step-6 Let’s containerise the app.

This image has an empty alt attribute; its file name is Screenshot-2020-08-09-at-12-40-19-AM-png-2886×1934-1-scaled.jpg

Step-7 Create .dockerignore file . It removes unwanted folders to push to container.

Step-8 Now let’s build and run image locally using below cmd

docker build --tag asif1202/demodocker:v1 .
docker run --name v1 -p 80:80 asif1202/demodocker:v1

Step-9-Let’s push this image to docker hub repository. First we need to login to docker hub account and push our docker image to the repository by using below commands.

docker login
docker push asif1202/demodocker:v1

Leave a Reply

Your email address will not be published. Required fields are marked *