dockerfile-guidelines
/dockerfile-guidelines
Provides Dockerfile best practices for this project. Claude should use this skill when creating or modifying Dockerfiles to ensure optimal layer caching by ordering instructions from most stable to least stable.
- Author
- humansintheloop-dev ↗
- Repository
- humansintheloop-dev-workflow-and-tools ↗
- Licence
- Apache-2.0
- Last repository change
- 26.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 1
No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
What it does and when to use it
Provides Dockerfile best practices for this project. Claude should use this skill when creating or modifying Dockerfiles to ensure optimal layer caching by ordering instructions from most stable to least stable.
Original author description
Provides Dockerfile best practices for this project. Claude should use this skill when creating or modifying Dockerfiles to ensure optimal layer caching by ordering instructions from most stable to least stable.
How it works
- Order Instructions by Descending Stability
SKILL.md preview
---
name: dockerfile-guidelines
description: Provides Dockerfile best practices for this project. Claude should use this skill when creating or modifying Dockerfiles to ensure optimal layer caching by ordering instructions from most stable to least stable.
---
# Dockerfile Guidelines
When creating or modifying Dockerfiles for this project, follow these guidelines:
## Order Instructions by Descending Stability
Dockerfile instructions should be ordered from most stable (least likely to change) to least stable (most likely to change). This maximizes Docker layer caching efficiency, resulting in faster builds.
### Recommended Order
1. **Base image** (`FROM`) - Changes rarely
2. **System dependencies** (`RUN apt-get`, `RUN apk add`) - Changes infrequently
3. **Environment variables** (`ENV`) - Changes occasionally
4. **Working directory** (`WORKDIR`) - Changes rarely
5. **Copy dependency manifests** (`COPY package.json`, `COPY requirements.txt`) - Changes when dependencies change
6. **Install dependencies** (`RUN npm install`, `RUN pip install`) - Changes when dependencies change
7. **Copy application code** (`COPY . .`) - Changes frequently during development
8. **Build steps** (`RUN npm run build`) - Changes when code changes
9. **Runtime configuration** (`EXPOSE`, `CMD`, `ENTRYPOINT`) - Changes occasionally
### Example
```dockerfile
# 1. Base image (most stable)
FROM node:20-alpine
# 2. System dependencies
RUN apk add --no-cache tini
# 3. Environment variables
ENV NODE_ENV=production
# 4. Working directory
WORKDIR /app
# 5. Copy dependency manifests first
COPY package.json package-lock.json ./
# 6. Install dependencies (cached unless manifests change)
RUN npm ci --only=production
# 7. Copy application code (least stable - changes often)
COPY . .
# 8. Build step
RUN npm run build
# 9. Runtime configuration
EXPOSE 3000
CMD ["/sbin/tini", "--", "node", "dist/index.js"]
```
### Example: Java Application with Pre-built JAR
```dockerfile
# Base image (most stable)
FROM eclipse-temurin:17-jre
WORKDIR /app
# Install system tools (stable - rarely changes)
RUN apt-get update && apt-get install -y curl ca-certificates wget && \
wget -O step-cli.tar.gz https://dl.smallstep.com/gh-release/cli/gh-release-header/v0.27.4/step_linux_0.27.4_$(dpkg --print-architecture).tar.gz && \
tar -xzf step-cli.tar.gz && \
mv step_0.27.4/bin/step /usr/local/bin/step && \
rm -rf step-cli.tar.gz step_0.27.4 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
EXPOSE 8443
# Copy entrypoint script (changes occasionally)
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Copy application JAR (changes frequently)
COPY build/libs/app.jar /app/app.jar
ENTRYPOINT ["/app/entrypoint.sh"]
```
### Why This Matters
Docker builds images in layers. When a layer changes, all subsequent layers must be rebuilt. By placing stable instructions first:
- Unchanged layers are retrieved from cache
- Only layers after the first change need rebuilding
- Development builds are significantly faster since code changes only invalidate the final layers
Versions
The database has no other skills named dockerfile-guidelines.
Database snapshot: 13.11.2026 · package version 637fe1ebbbca (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95dockerfile-validator
Validates, lints, and secures Dockerfiles by running syntax checking, detecting security vulnerabilities, validating layer ordering, checking for hardcoded secrets, verifying base image tags, and analyzing build optimization. Use when validating Dockerfile syntax, checking… - 100dockerfile-optimise
Dockerfile optimization guidelines from official Docker documentation. This skill should be used when writing, reviewing, or refactoring Dockerfiles to ensure optimal build time, image size, security, and robustness. Triggers on tasks involving Dockerfile creation, Docker image… - 100s06-01-dockerfile
编写多阶段构建 Dockerfile 与镜像优化方案,含非 root 运行与健康检查。当用户要求'写 Dockerfile/容器化'时使用。产出 Dockerfile 与构建说明。 - 100dockerfile-patterns
Use when the user asks about writing, optimizing, or debugging Dockerfiles, containerizing applications, or building Docker images with docker build. Covers multi-stage builds, layer caching, base image selection, security hardening, and language-specific patterns for Python,… - 100dockerfile-generator
Generate dockerfile generator operations. Auto-activating skill for DevOps Basics. Triggers on: dockerfile generator, dockerfile generator Part of the DevOps Basics skill category. Use when working with dockerfile generator functionality. Trigger with phrases like "dockerfile… - 100dockerfile-generator
Generate an optimized multi-stage Dockerfile and .dockerignore for a .NET app — small final image, layer caching, non-root user, and best practices. Use this skill whenever the user wants a Dockerfile, to containerize a .NET app, a multi-stage build, smaller images,…