dockerfile

Create multi-stage Dockerfiles for .NET applications with health checks and caching.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill dockerfile-faysilalshareef
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dockerfile
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/devops/dockerfile
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill dockerfile-faysilalshareef

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill removes guesswork and inefficiency from containerizing .NET applications by providing clear, production-oriented Dockerfile patterns that reduce image size, improve build caching, and enforce runtime security.

Core Features & Use Cases

  • Multi-stage build patterns that separate build, publish, and runtime stages to produce minimal runtime images.
  • Layer-caching strategy by copying project files before restore, version-aware base images, non-root user enforcement, health check integration, and a recommended .dockerignore.
  • Use Case: Convert an ASP.NET or background worker project into a CI-friendly multi-stage Docker image with health checks and optimized caching for faster pipeline runs.

Quick Start

Generate a multi-stage Dockerfile for a .NET 8 ASP.NET application that copies csproj files first, publishes to /app/publish, runs as a non-root user, exposes port 8080, and includes a health check.

Frequently Asked Questions about dockerfile

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

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

Create a multi-stage Dockerfile for ASP.NET by separating build, publish, and runtime stages to produce minimal images. This skill generates Dockerfiles that copy csproj files first for layer caching, publish to /app/publish, and enforce a non-root user.

What's the best way to reduce .NET Docker image size and improve build caching?

Reduce .NET Docker image size and improve caching by copying project files before restore to leverage Docker layer caching. This skill produces minimal runtime images using version-aware Alpine bases and multi-stage builds to optimize CI/CD pipeline runs.

Does this Dockerfile skill support adding health checks and .dockerignore configurations?

Yes, this Dockerfile skill supports adding health checks and generates a recommended .dockerignore file. The produced Dockerfiles include healthcheck configurations and .dockerignore setups to further optimize container builds and runtime monitoring.

Can I use this skill to containerize a .NET worker service for CI/CD pipelines?

Yes, you can use this skill to containerize a .NET worker service for CI/CD pipelines. It applies multi-stage build patterns, optimized layer caching, and non-root user enforcement to both ASP.NET and background worker projects.

How does enforcing a non-root user in a .NET container improve security?

Enforcing a non-root user in a .NET container improves security by limiting runtime privileges. This skill generates production-oriented Dockerfiles that enforce non-root users alongside version-aware Alpine images to harden runtime security.

Why should I copy csproj files before running dotnet restore in a Dockerfile?

Copy csproj files before running dotnet restore in a Dockerfile to maximize layer caching efficiency. This skill uses this pattern so dependency changes trigger restores while code changes utilize cached layers, accelerating CI/CD pipeline builds.