.Net Core 3.0 + docker

There is always my life before docker and my life after docker. Docker has changed my day-to-day development life very significantly. I almost don’t have to worry about installing or configuring any dependencies anymore.

I found this to be extremely beneficial especially in a microservice world where every service has a ton of dependencies.

In this post, I am going to give an example of using docker to create a .NET Core 3.0 ASP.NET MVC Core service running and building in docker. To make things more interesting I am ditching my windows machine for this exercise and sticking with my MacBook!

So what is docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

https://opensource.com/resources/what-docker

I will start by creating a new .net web API app

dotnet new webapi

To make sure things are working, go to your terminal and run:

dotnet run

then point your browser to https://localhost:5001/Weatherforecast, you should see something similar to this:

successful API call

Now I am going to add a Dockerfile and .dockerignore to build and run our .NET Core 3.0 app (swap APP_NAME for your application name)

To build and run the docker image:

docker build -t aspnetapp .
docker run -d -p 8080:80 --name myapp aspnetapp

Hit http://localhost:8080/weatherforecast in your browser!

Credit & more information => docker docs

Hello world

I decided to start blogging about my coding adventures. I have a feeling this is going to help me keep more of my adventures in my mind and it could be a way to help others through their individual adventures.

I have no prior blogging experience so things might be a bit rough. Hopefully, this will change for the better as I gain more experience.

I have been putting off blogging for too long now. Well no more!

unsplash-logoAkshay M