Member-only story
Containerize an ASP.NET Core Web API with Docker
Containerize a Web API for easy mocking and testing by Front-End developers
As Front-End developers we are sometimes faced with situations where we need to run back-end code on our local Dev machines just to make API requests. This is when Docker can come in handy.
Today we will look at how we can containerize an ASP.NET Web API using Docker. By so doing, instead of running back-end code on your Dev machine you instead just spin up an instance of a Docker image. The good thing is that, you can run the same Docker image in different environments without other extra configurations and customization.
Here are some of the tools or software we will use:
- ASP.NET Core SDK 3.1
- Docker
- Visual Studio Code (VS Code)
Also make sure to install the Docker extension for VS Code by Microsoft. To install it, simply click on extensions or press Ctrl + Shift + x
. Search for Docker and click install.
We can now create an ASP.NET Core web API by running the following command within our projects folder: dotnet new webapi -o IntroToMvc --no-http
. This creates a dotnet web API named IntroToMvc and places it in a similarly named folder. To run the project…