```html .NET Core Docker Introduction

.NET Core Docker Docs

Introduction to Docker with .NET Core

Docker enables you to package and run .NET Core applications in lightweight, portable containers. This guide walks you through the fundamentals of containerizing a .NET Core app, from creating a Dockerfile to building and running your container.

Why Docker?

Sample Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MyApp/MyApp.csproj", "MyApp/"]
RUN dotnet restore "MyApp/MyApp.csproj"
COPY . .
WORKDIR "/src/MyApp"
RUN dotnet build "MyApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]

Build the Image

docker build -t myapp:latest .

Run the Container

docker run -d -p 8080:80 --name myapp_container myapp:latest

Open http://localhost:8080 in your browser to see the running application.

Next Steps

Explore more detailed topics:

```