docker-build

Builds, debugs, and optimizes Dockerfiles and container image builds across languages.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/jason23452/my-skill --skill docker-build-jason23452
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docker-build
Source: https://github.com/jason23452/my-skill/tree/main/devops/docker-build
Command: npx skills add https://github.com/jason23452/my-skill --skill docker-build-jason23452

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Docker builds often fail due to wrong build contexts, poor layer caching, oversized images, or missing files, and debugging them wastes significant time. This Skill provides structured guidance for writing, fixing, and optimizing Dockerfiles and image builds for any project type. ## Core Features & Use Cases - Dockerfile Authoring & Optimization: Applies multi-stage builds, lockfile-first layer ordering for cache reuse, pinned base images, non-root runtime users, and .dockerignore hygiene for Node, Python, Go, and Java projects. - Build Debugging: Diagnoses failures by locating the failing stage, checking build context versus Dockerfile paths, verifying lockfile and package manager compatibility, and using --progress=plain or --no-cache when needed. - Bootstrap Scripts: Generates a starter Dockerfile and .dockerignore tailored to detected project type (Node, Python, or generic) via executable scripts. - Use Case: Your FastAPI build fails with "COPY requirements.txt not found" even though the file exists in backend/. The Skill identifies the build context mismatch and recommends running docker compose build or fixing the COPY path. ## Quick Start Ask the AI to containerize your project or fix a failing Docker build, for example: "Improve my Dockerfile caching and give me the right docker build command for my Node app."

Frequently Asked Questions about docker-build

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

FAQPage Schema
How do I improve Docker build caching for a Node project?▼

Copy package.json and the lockfile first, run the install command, then copy the full source so dependency layers are reused. Add a .dockerignore excluding node_modules, dist, and .git to keep the build context small and cache stable.

Why does Docker build fail with COPY file not found?▼

The file is usually outside the build context, excluded by .dockerignore, or referenced before it is copied. Check the build context path in docker-compose.yml and run docker build with --progress=plain to see the exact failing instruction.

Should I use docker build or docker compose build?▼

Prefer docker compose build when the project defines the service in Compose, since it includes build args, targets, and context paths. Running docker build directly may miss those settings and produce a different image.

How do I build a small production Docker image for Go?▼

Use a multi-stage build: copy go.mod and go.sum, run go mod download, then compile in a builder stage. For runtime, choose distroless, scratch, or Debian slim depending on TLS certificates, shell access, and CGO requirements.

What base image should I use for a Python FastAPI Dockerfile?▼

Use a pinned image like python:3.12-slim and install dependencies from a lockfile with uv, Poetry, or pip. Keep build tools in a builder stage and copy only runtime files such as migrations, templates, and static assets into the final image.

When should I use docker build --no-cache?▼

Use --no-cache when diagnosing suspected cache corruption or stale dependency layers. For ordinary build failures, first locate the failing stage and dependency layer from the logs before discarding the cache.