Skip to content

About

Dockerized .NET API is a simple ASP.NET Core Web API project, containerized using Docker. This repository serves as a beginner-friendly example for running a .NET 9 API inside a Docker container.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Dockerized DotNet API

A simple .NET API running inside a Docker container.

How to Run (Using Docker CLI)

  1. Build the Docker image:
    docker build -t dockerized-dotnetapi .
  2. Run the Docker container:
    docker run -d -p 2501:80 --name mydockerapi-container dockerized-dotnetapi
  3. Access the API:

How to Run (Using Docker Compose)

  1. Start the container:
    docker-compose up -d
  2. Stop and remove containers:
    docker-compose down
  3. Rebuild the image (if changes are made):
    docker-compose up --build -d
  4. Access the API:

Environment Configuration

By default, the API runs in Production mode inside the Docker container.
You can override this setting by passing an environment variable when running the container:

docker run -d -p 2501:80 -e ASPNETCORE_ENVIRONMENT=Development --name mydockerapi-container dockerized-dotnetapi

To verify the environment mode, open:

Logging Configuration

The application logs startup events into a file inside the container:

  • Logs are stored in /app/logs/log.txt.
  • If the directory does not exist, it is created automatically.

Project Structure

Dockerized-DotNetAPI/
│-- Dockerfile
│-- docker-compose.yml
│-- Dockerized-DotNetAPI.csproj
│-- Program.cs
│-- logs/ (generated at runtime)

Notes

  • This project demonstrates a basic .NET API inside a Docker container.
  • Supports both Docker CLI and Docker Compose for running the application.
  • Ensure Docker is installed and running before executing the commands.
  • Includes basic logging to track application startup.

About

Dockerized .NET API is a simple ASP.NET Core Web API project, containerized using Docker. This repository serves as a beginner-friendly example for running a .NET 9 API inside a Docker container.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages