This document uses self-signed development certificates for hosting pre-built images over localhost. The instructions are similar to using production certificates.
For production certificates:
The dotnet dev-certs tool is not required.
Certificates don't need to be stored in the location used in the instructions. Store the certificates in any location outside the site directory.
The instructions contained in the following section volume mount certificates into containers using the volumes property in docker-compose.yml. You could add certificates into container images with a COPY command in a Dockerfile, but it's not recommended. Copying certificates into an image isn't recommended for the following reasons:
It makes it difficult to use the same image for testing with developer certificates.
It makes it difficult to use the same image for Hosting with production certificates.
There is significant risk of certificate disclosure.
Starting a container with https support using docker compose
Use the following instructions for your operating system configuration.
On Linux, dotnet dev-certs https --trust requires .NET 9 SDK or later. For Linux on .NET 8.0.401 SDK and earlier, see your Linux distribution's documentation for trusting a certificate.
In the preceding commands, replace $CREDENTIAL_PLACEHOLDER$ with a password.
Create a docker-compose.debug.yml file with the following content:
This document uses self-signed development certificates for hosting pre-built images over localhost. The instructions are similar to using production certificates.
For production certificates:
The dotnet dev-certs tool is not required.
Certificates don't need to be stored in the location used in the instructions. Store the certificates in any location outside the site directory.
The instructions contained in the following section volume mount certificates into containers using the volumes property in docker-compose.yml. You could add certificates into container images with a COPY command in a Dockerfile, but it's not recommended. Copying certificates into an image isn't recommended for the following reasons:
It makes it difficult to use the same image for testing with developer certificates.
It makes it difficult to use the same image for Hosting with production certificates.
There is significant risk of certificate disclosure.
Starting a container with https support using docker compose
Use the following instructions for your operating system configuration.
dotnet dev-certs https --trust is only supported on macOS and Windows. You need to trust certificates on Linux in the way that is supported by your distribution. It is likely that you need to trust the certificate in your browser.
In the preceding commands, replace $CREDENTIAL_PLACEHOLDER$ with a password.
Create a docker-compose.debug.yml file with the following content:
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
ASP.NET Core feedback
ASP.NET Core is an open source project. Select a link to provide feedback:
Create independently deployable, highly scalable, and resilient apps and services using the free and open-source .NET platform. With .NET you can use popular microservice technology like Docker, Kubernetes, Dapr, Azure Container Registry, and more for .NET and ASP.NET Core applications and services.
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.