docker

Build multi-stage Docker images for .NET 10 apps with non-root execution.

224|87|Updated Dec 15, 2018
One-click install
npx skills add https://github.com/Resgrid/Core --skill docker-resgrid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker
Source: https://github.com/Resgrid/Core/tree/main/.opencode/skills/docker
Command: npx skills add https://github.com/Resgrid/Core --skill docker-resgrid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Docker containerization for .NET 10 applications can be error-prone and inefficient when builds are slow, images are oversized, and containers run with insecure permissions.

Core Features & Use Cases

  • Multi-stage Docker builds: Use separate build and runtime stages to reduce image size and improve build efficiency.
  • Non-root containers by default: Configure the runtime image to run as a non-root user for better security.
  • Health checks and orchestration readiness: Add HEALTHCHECK and align local orchestration (e.g., Docker Compose) with service health dependencies.
  • .dockerignore best practices: Exclude common directories and files (like git, build outputs, node modules) to prevent bloated build contexts.
  • Use-case fit: Containerize Web APIs or worker services, optimize Dockerfile layers for caching, and set up local development via Docker Compose.

Quick Start

Create a multi-stage Dockerfile that restores via copied .csproj files, publishes with dotnet publish, runs on the ASP.NET runtime image as a non-root user, and adds a HEALTHCHECK endpoint for /health/live.

Frequently Asked Questions about docker

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a multi-stage Dockerfile for a .NET 10 application?

A multi-stage Dockerfile for .NET 10 separates build and runtime stages to reduce image size. You restore via .csproj files, publish with dotnet publish, and run on the ASP.NET runtime image as a non-root user.

Why should my .NET Docker containers run as a non-root user?

Running .NET Docker containers as a non-root user improves security by limiting permissions. The runtime image is configured to execute the ASP.NET application with a secure USER setup, reducing vulnerability exposure.

What's the best way to reduce Docker image size for .NET worker services?

The best way to reduce Docker image size for .NET worker services is using multi-stage builds. Separating build and runtime stages and applying .dockerignore best practices minimizes build context and excludes unnecessary files.

How do I configure Docker Compose health checks for local .NET development?

Configure Docker Compose health checks for local .NET development by adding a HEALTHCHECK instruction for the /health/live endpoint. This aligns local orchestration with service health dependencies for reliable startup.

Why is my Docker build context so large for .NET applications?

Your Docker build context is large because common directories like git, build outputs, and node modules are included. Applying .dockerignore best practices excludes these files to prevent bloated build contexts and slow builds.