docker-best-practices

Applies Docker best practices for Dockerfiles, images, containers, and Compose deployments.

2|Updated May 9, 2026
One-click install
npx skills add https://github.com/Manuel-Gartenkrot-Casal/AfterDrive_Intelligence --skill docker-best-practices-manuel-gartenkrot-casal
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docker-best-practices
Source: https://github.com/Manuel-Gartenkrot-Casal/AfterDrive_Intelligence/tree/main/.agents/skills/docker-best-practices
Command: npx skills add https://github.com/Manuel-Gartenkrot-Casal/AfterDrive_Intelligence --skill docker-best-practices-manuel-gartenkrot-casal

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Dockerfiles and Compose configurations that are secure, small, and reproducible requires knowing many scattered rules about base images, layer caching, secrets, and runtime hardening, and mistakes lead to bloated or vulnerable containers. ## Core Features & Use Cases - Dockerfile Authoring: Provides templates for multi-stage builds, optimal layer ordering, base image selection (Alpine, distroless, slim, Chainguard), and .dockerignore hygiene. - Runtime Hardening: Covers non-root users, dropped capabilities, read-only filesystems, resource limits, health checks, logging rotation, and restart policies. - Compose & Production Guidance: Includes network isolation, dependency health conditions, secrets management, tagging strategies, and rolling update configurations. - Use Case: When containerizing a Node.js or Python service, use this Skill to generate a multi-stage Dockerfile with a non-root user, health check, and pinned base image, plus a Compose file with resource limits and isolated networks. ## Quick Start Ask the assistant to write a production-ready Dockerfile and docker-compose.yml for your application following Docker best practices.

Frequently Asked Questions about docker-best-practices

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

FAQPage Schema
How do I write a production-ready Dockerfile?▼

Use a multi-stage build with a pinned minimal base image like node:20-alpine or python:3.12-slim, order layers from least to most frequently changing, run as a non-root user, and add a HEALTHCHECK instruction. Never use the latest tag or embed secrets in layers.

What base image should I use for Docker containers?▼

Choose based on needs: Chainguard or Wolfi images for minimal CVEs, Alpine for small size around 7MB, distroless for no shell and maximum hardening, or slim variants for a balance of compatibility and size. Always pin exact version tags.

How do multi-stage builds reduce Docker image size?▼

Multi-stage builds separate build dependencies from runtime by compiling in a builder stage and copying only the artifacts into a clean final stage. This excludes compilers, dev dependencies, and build tools from the shipped image.

How do I handle secrets in Docker containers?▼

Never put secrets in ENV instructions or image layers since they persist in history. Use Docker secrets in Swarm mode, mount secret files at runtime as read-only volumes, or pass environment files with --env-file that are excluded from version control.

Why is my Docker build slow and how do I fix it?▼

Slow builds usually come from poor layer ordering that invalidates the cache. Copy dependency manifests before application code, enable BuildKit, and use cache mounts for package managers so dependency layers are reused across builds.

Does Docker Compose need a version field in the file?▼

No, the version field is obsolete in Compose v2 and should be omitted. Modern Compose files start directly with the services key and support features like healthcheck-based depends_on conditions and internal networks.