- Scaffold and run a simple ASP.NET Core Razor Pages application
- Containerize the app using Docker Desktop
- Optionally pull a pre-built image from Docker Hub
Prerequisites
Make sure you have the following installed:Ensure Docker Desktop is running before you build or pull any images.
1. Creating the ASP.NET Core Application
We’ll scaffold a basic Razor Pages app and review theIndexModel class. Create a new project and replace the contents of Pages/Index.cshtml.cs with:
2. Containerizing with Docker
At the root of your ASP.NET project, add aDockerfile similar to:
After completion, you’ll have an image tagged
yourrepo/kodekloudapp:latest.
3. Using a Pre-built Image (Optional)
If you’d rather skip local builds, pull the image directly from Docker Hub:You can browse Docker Hub and search for
yourrepo/kodekloudapp to verify the image and get the exact pull command.