liveBook · Manning

Docker

As explained in Pro ASP.NET Core 7, Tenth Edition

A Docker container is an isolated process environment created and run by Docker with its application and dependencies.

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

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Builds and runs an application image with Dockerfile and Compose steps, but stops short of a complete deployment guide.
Examples
Uses SportsStore, a .NET 7 Dockerfile, Docker Compose services, SQL Server, and the localhost:5000 endpoint.
What it assumes
Assumes an ASP.NET Core application and database connection settings, while explaining Docker installation, Dockerfile structure, image building, and container startup.
What you can do after
Operate/configure Docker Desktop, build the SportsStore image, start its database and application containers, and verify the running endpoint.
How it connects
Connects ASP.NET Core, Dockerfile, Docker Compose, SQL Server, container images, environment settings, and port mapping.

Also explained in

Compare how 26 books explain Docker →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.