docker-best-practices

Automate Docker container creation and optimization with multi-stage builds, non-root execution, and health checks.

10|5|Updated Dec 12, 2025
One-click install
npx skills add https://github.com/ils15/mythic-agents --skill docker-best-practices-ils15
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-best-practices
Source: https://github.com/ils15/mythic-agents/tree/main/skills/docker-best-practices
Command: npx skills add https://github.com/ils15/mythic-agents --skill docker-best-practices-ils15

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dockerfile creation and container optimization can be error-prone and inconsistent across teams. This skill provides a collection of best practices to generate lean, secure, and maintainable Dockerfiles and docker-compose configurations.

Core Features & Use Cases

  • Multi-stage builds for smaller images and faster builds.
  • Security hardening with non-root users, minimal base images, and reduced privileges.
  • Health checks and proper docker-compose patterns for development and production.
  • Layer caching and cleanup patterns to optimize image size and build times.
  • Guidance for production-ready deployments and development parity.

Quick Start

Use the docker-best-practices skill to review an existing Dockerfile and docker-compose.yml, then apply the recommended patterns to reduce image size and improve security.

Frequently Asked Questions about docker-best-practices

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

FAQPage Schema
What is the best way to optimize Docker image size and build times?

Optimizing Docker image size involves using multi-stage builds and proper layer caching patterns. This approach separates build dependencies from runtime environments, reducing image size and accelerating build processes.

How do I configure a non-root user in a Dockerfile for security hardening?

Configuring a non-root user in a Dockerfile requires adding a dedicated user and switching to it before the entrypoint. This security hardening practice reduces privileges and limits potential container exploitation risks.

How do I add health checks to docker-compose configurations for production readiness?

Adding health checks to docker-compose configurations involves defining healthcheck parameters in the service definition. This ensures reliable service orchestration by monitoring container health and managing restarts in production deployments.

Does this Docker optimization approach support both development and production environments?

Yes, this Docker optimization approach applies to both development and production environments. It provides production-ready docker-compose configurations while maintaining development parity through consistent containerization patterns.

Why should I use multi-stage builds in my Dockerfile?

You should use multi-stage builds in your Dockerfile to create smaller images and faster builds. This technique copies only necessary artifacts from build stages to final images, discarding unnecessary dependencies and tools.