dockerfile-best-practices

Generate or review Dockerfiles for secure, efficient container images.

6|1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/wesleyosantos91/multi-agents --skill dockerfile-best-practices-wesleyosantos91
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dockerfile-best-practices
Source: https://github.com/wesleyosantos91/multi-agents/tree/main/devin/.devin/skills/dockerfile-best-practices
Command: npx skills add https://github.com/wesleyosantos91/multi-agents --skill dockerfile-best-practices-wesleyosantos91

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents insecure, bloated, or slow Docker images by guiding you to write Dockerfiles that follow proven security and performance conventions.

Core Features & Use Cases

  • Security hardening: enforces non-root execution, avoids secrets in build stages, and encourages vulnerability scanning.
  • Performance optimization: uses multi-stage builds, improves build caching via lockfiles, and reduces image size with minimal base images.
  • Maintainability & reproducibility: encourages deterministic tags (no latest), layer ordering, and a well-curated .dockerignore.
  • Language templates: provides ready-to-adapt Dockerfile patterns for Java (Maven), Python (uv), Go, and Node.js.

Quick Start

Ask for a Dockerfile review for your existing project and include the target language and runtime version, for example: "Review my Dockerfile and rewrite it to follow best practices for a Node.js 22 app, ensuring non-root execution, multi-stage builds, a proper tag (no latest), and an optimized .dockerignore."

Frequently Asked Questions about dockerfile-best-practices

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

FAQPage Schema
How do I write a secure Dockerfile for production?

To write a secure Dockerfile, enforce non-root execution, avoid secrets in build stages, and use pinned deterministic base image tags instead of latest. Applying multi-stage builds and optional vulnerability scanning further hardens containers for production delivery.

What's the best way to optimize Docker image size and build caching?

Optimize Docker image size by using multi-stage builds to separate build and runtime environments, and selecting minimal base images. Improve build caching by structuring layer ordering efficiently and leveraging lockfiles for dependency resolution workflows.

Does this Dockerfile review tool support Python and Node.js applications?

Yes, this Dockerfile review tool supports Python and Node.js applications, alongside Java and Go. It provides ready-to-adapt Dockerfile patterns and dependency caching workflows specific to each language runtime, ensuring proper containerization.

How do I configure a .dockerignore file to reduce image size?

Configure a .dockerignore file by excluding unnecessary build artifacts, local dependencies, and secrets from the Docker build context. Curating this file reduces the final image size and prevents accidental secret leakage during the image build process.

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

Use multi-stage builds in your Dockerfile to significantly reduce final image size by copying only compiled binaries or runtime artifacts from the build stage. This technique strips out unnecessary build tools and dependencies from the production image.

Can I scan my Docker image for vulnerabilities after building it?

Yes, you can scan your Docker image for vulnerabilities after building. The Dockerfile generation process encourages integrating optional vulnerability scanning steps into your workflow to identify and address security issues before production delivery.