Articles

Deploy an ASP.NET Core .NET 10 API with Docker

Build a minimal ASP.NET Core API for Linux, bind Kestrel to the host port, deploy to Gregale, and verify the exact release response.

Updated

Deploy an ASP.NET Core .NET 10 API to Gregale with a Linux Dockerfile. Use Microsoft's SDK image to build and its ASP.NET runtime image to run. Set Kestrel to listen on 0.0.0.0 and the port Gregale passes in PORT. A Dockerfile is the path for this example; it does not depend on a native .NET builder.

View the source on GitHub or download the complete .NET 10 example. It starts a minimal API without a database, credentials, or external packages. GET /ready returns a marker from inside the application, and GET /greet/world returns {"message":"Hello, world!"}.

Match the container's port to the host

Inside the container, localhost is private to the process. Kestrel must listen on all interfaces so Gregale can route requests to it. Microsoft's ASP.NET container images default to port 8080, but making the application read PORT avoids a mismatch when the host sets a different port.

csharp
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
if (!int.TryParse(port, out var listenPort) || listenPort is < 1 or > 65535)
{
    throw new InvalidOperationException("PORT must be a TCP port between 1 and 65535.");
}
builder.WebHost.UseUrls(
quot;http://0.0.0.0:{listenPort}");

The Dockerfile declares EXPOSE 8080 and starts dotnet GreetingApi.dll as the image's non-root user. EXPOSE documents the port; it does not tell Kestrel to bind. Gregale terminates HTTPS before requests reach the container. The server listens over HTTP internally, so the sample does not redirect its internal readiness request to HTTPS.

Run it locally

Unzip the sample, change into the extracted directory, and run:

bash
docker build --platform linux/amd64 -t aspnet-greeting .
docker run --rm -p 8080:8080 -e PORT=8080 aspnet-greeting

In a second terminal:

bash
curl -fsS http://localhost:8080/ready
curl -fsS http://localhost:8080/greet/world

The example's gregale.yaml sets hosting.health: /ready, an endpoint served by this application rather than a platform liveness URL.

Deploy and verify on Gregale

Install the Gregale CLI, then authenticate and deploy from the extracted directory. Pick a fresh name rather than reusing a production app.

bash
gregale login
gregale deploy --path . --name aspnet-greeting

A successful deploy prints the app URL. If the app allows public requests, send a GET to its URL and check the JSON. For a private app, use the deployment UUID reported by gregale --json deploy or shown on the release page:

bash
gregale release verify DEPLOYMENT_UUID --app aspnet-greeting --path /ready
gregale release verify DEPLOYMENT_UUID --app aspnet-greeting --path /greet/world

A passing readiness check doesn't prove your business endpoint works. Check that the second call returns the expected greeting. Owner-authorized release verification checks the specified revision; it does not prove anonymous access or which version serves public traffic.

What passed on Gregale

On December 1, 2026, we deployed the exact sample from a Dockerfile to a disposable app on a Scale account. Owner-authorized GETs returned HTTP 200 with the expected readiness marker and {"message":"Hello, world!"}. We then staged a second build using gregale deploy --no-traffic. Its exact release returned {"message":"Preview hello, world!"} while the first release retained 100% of routing and its original response. The second release had 0%. This tests a staged release; it is not a GitHub PR preview or a fresh Free-account verification.

If the deploy builds but never becomes ready

SymptomCheck
Readiness times outConfirm Kestrel binds to 0.0.0.0:$PORT, not localhost.
/ready is 404Confirm it is mapped in Program.cs and the deployed image includes that source.
Wrong architectureBuild for linux/amd64, especially on Apple Silicon.
App runs but the public request is unauthorizedVerify the app's access policy; keep the API private unless it is intended for anonymous use.

When you are done, remove only the test app you created. Do not reuse these commands against an existing service without reviewing the target.

Sources: Microsoft: .NET container port defaults, Gregale container compatibility, and Gregale: deployment verification.

Questions

Can you deploy an ASP.NET Core .NET 10 API to Gregale?

Yes, deploy a Linux Dockerfile with the .NET runtime in the image. This guide uses the container path, not a native .NET builder.

What port should ASP.NET Core listen on in Docker?

Bind Kestrel to 0.0.0.0 and read the PORT environment variable from the host. This sample falls back to 8080 when PORT is unset.

How do you verify a private deployment without making it public?

Use gregale release verify with the exact deployment UUID and your application path. It runs an authenticated GET and does not verify public access.