Docker packages an ASP.NET Core application and its dependencies into a containerized process environment that can run across hosting platforms or in a private data center. The deployment workflow builds an image, starts supporting services, and verifies the application through its published HTTP endpoint. section 11.6 section 11.6.4
A practical ASP.NET Core container workflow is:
- Install Docker Desktop and verify the command-line installation with docker --version. section 11.6.3
- Publish the application in Release configuration with dotnet publish -c Release. section 11.6.3
- Define the runtime image, published files, environment, working directory, exposed port, and entry point in a Dockerfile. section 11.6.3
- Use Docker Compose to build the application image and describe the application and SQL Server services. section 11.6.3
- Start SQL Server, start the application container, request http://localhost:5000, and stop both services with Control+C. section 11.6.4
Listing 11.20 The contents of the Dockerfile File in the SportsStore folder
FROM mcr.microsoft.com/dotnet/aspnet:7.0 COPY /bin/Release/net7.0/publish/ SportsStore/ ENV ASPNETCORE_ENVIRONMENT Production ENV Logging__Console__FormatterName=Simple EXPOSE 5000 WORKDIR /SportsStore ENTRYPOINT ["dotnet", "SportsStore.dll", "--urls=http://0.0.0.0:5000"]
The Dockerfile uses the ASP.NET Core 7.0 runtime image, copies published output into /SportsStore, sets Production configuration, exposes port 5000, and launches SportsStore.dll. section 11.6.3
Running SportsStore
Run docker-compose up sqlserver, then docker-compose up sportsstore. Once the logs report that the application is listening on http://0.0.0.0:5000, open http://localhost:5000 to use the containerized application. section 11.6.4
A Dockerfile keeps image configuration explicit rather than delegating it to newer .NET project-file image tooling. Database connection strings and container networking must be adapted for production; connecting to a development-machine database is only a setup example. section 11.6.3

























