docker-patterns

Configure Docker Compose multi-service setups with health checks and non-root containers.

Updated May 11, 2026
One-click install
npx skills add https://github.com/CZ-X-Ya/oh-my-csharp-skills --skill docker-patterns-cz-x-ya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-patterns
Source: https://github.com/CZ-X-Ya/oh-my-csharp-skills/tree/main/docker-patterns
Command: npx skills add https://github.com/CZ-X-Ya/oh-my-csharp-skills --skill docker-patterns-cz-x-ya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the confusion and fragility of building local multi-container development environments by providing practical, secure Docker and Docker Compose patterns for networking, storage, and production-ready containerization.

Core Features & Use Cases

  • Local multi-service orchestration: Use Compose service discovery, health checks, and dependency ordering to reliably run app + database + cache + tooling together.
  • .NET/ASP.NET Core containerization: Apply multi-stage Docker builds, non-root runtime hardening, health checks, and environment-driven configuration for stable deployments.
  • Operational patterns: Manage volumes correctly, use override files for dev/prod differences, and maintain a clean build context with .dockerignore to reduce image size and build time.
  • Use Case: When migrating a local workflow from “run everything on the host” to Docker Compose, apply the provided patterns to get hot-reload for the API, persistent Postgres storage, working Redis connectivity, and a safe runtime image configuration.

Quick Start

Ask the assistant: "Generate a docker-compose setup for a .NET 8 API with PostgreSQL and Redis using non-root containers, health checks, a migrations one-shot service profile, and a dev hot-reload bind mount."

Frequently Asked Questions about docker-patterns

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

FAQPage Schema
How do I set up Docker Compose for an ASP.NET Core API with PostgreSQL and Redis?

You orchestrate an ASP.NET Core API with PostgreSQL and Redis using Docker Compose by defining multi-stage Dockerfiles, service health checks with depends_on conditions, and non-root runtime hardening to ensure reliable local development and safer container deployments.

What is the correct way to use Docker Compose health checks and depends_on for service startup?

Docker Compose health checks and depends_on conditions ensure reliable multi-service orchestration by preventing your ASP.NET Core API from starting until PostgreSQL and Redis pass their designated health checks, avoiding connection failures during local development.

How do I configure a non-root runtime user in a Docker container for .NET applications?

Configuring a non-root runtime user in a Docker container for .NET applications involves applying hardened runtime configuration in your multi-stage Dockerfile, ensuring safer container deployments by preventing the ASP.NET Core process from executing with root privileges.

What's the best way to manage dev and prod Docker Compose overrides?

The best way to manage dev and prod Docker Compose overrides is using separate override files with appropriate file exclusions to maintain a clean build context, enabling dev hot-reload bind mounts while keeping production containerization secure and optimized.

Does Docker Compose work with a one-shot migrations service profile for .NET APIs?

Yes, Docker Compose supports a one-shot migrations service profile for .NET APIs by leveraging service profiles to execute database migrations independently, ensuring your PostgreSQL schema is updated before the main ASP.NET Core application container starts.

Why do I need a .dockerignore file when building Docker images?

You need a .dockerignore file when building Docker images to maintain a clean build context, which directly reduces final image size and decreases build time by excluding unnecessary files from being sent to the Docker daemon during the multi-stage build process.