Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pluginagentmarketplace avatar

Dockerfile Basics

  • 23 installs
  • 2 repo stars
  • Updated January 5, 2026
  • pluginagentmarketplace/custom-plugin-docker

dockerfile-basics is an agent skill that provides a production-ready multi-stage Node Dockerfile template and Hadolint linting workflow.

About

dockerfile-basics teaches agent-assisted Dockerfile fundamentals for solo builders shipping Node services in containers. The bundled production template walks through a three-stage pattern—dependency install with npm ci, build stage, and a minimal runner that copies dist and node_modules under a non-root user—so you do not hand-roll insecure single-stage images on deploy day. The skill also documents layer optimization, security pinning, and performance habits, plus a small shell wrapper to lint any Dockerfile via local Hadolint or the official Hadolint container image. Use it when you are moving from a working local build to something registry-ready for Fly, ECS, Kubernetes, or any Docker host. It pairs naturally with CI that builds and scans images; it does not replace orchestration manifests or cloud-specific deploy skills. Complexity is beginner-friendly for the template copy path and intermediate if you customize stages for monorepos or alternate runtimes.

  • Multi-stage Dockerfile template: deps, builder, and runner with node:20-alpine
  • Security defaults: non-root nextjs user (uid 1001), NODE_ENV=production, pinned base image
  • Best-practice checklist: layer ordering, .dockerignore, combined RUN, alpine/slim images
  • Hadolint-based dockerfile-lint.sh with Docker fallback when hadolint is not installed
  • Performance guidance: build-cache-friendly COPY order and multi-stage separation

Dockerfile Basics by the numbers

  • 23 all-time installs (skills.sh)
  • Ranked #897 of 1,453 DevOps & CI/CD skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 26, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-docker --skill dockerfile-basics

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs23
repo stars2
Security audit3 / 3 scanners passed
Last updatedJanuary 5, 2026
Repositorypluginagentmarketplace/custom-plugin-docker

What it does

Scaffold a multi-stage production Dockerfile for Node apps and lint it with Hadolint before you containerize and deploy.

Who is it for?

Best when you're containerizing a Node 20 app and want a vetted starter Dockerfile and quick lint loop.

Skip if: Pure serverless deploys with no containers, or advanced polyglot monorepos needing bespoke base images without adaptation.

When should I use this skill?

You need to learn Dockerfile fundamentals or apply the production-ready Node template and lint script before building container images.

What you get

You produce a hardened, cache-friendly Dockerfile and can run Hadolint feedback before building the production image.

  • Production-oriented Dockerfile
  • Hadolint lint results for the Dockerfile
  • Applied layer and security best-practice notes

By the numbers

  • 3-stage Dockerfile pattern: deps, builder, runner
  • dockerfile-lint.sh supports local Hadolint or hadolint/hadolint Docker image

Files

SKILL.mdMarkdownGitHub ↗

Dockerfile Basics Skill

Master Dockerfile fundamentals and 2024-2025 best practices for building secure, optimized container images.

Purpose

Provide comprehensive guidance on Dockerfile syntax, instruction ordering, layer optimization, and security best practices.

Parameters

ParameterTypeRequiredDefaultDescription
base_imagestringNo-Base image to use
languagestringNo-Programming language (node/python/go/java)
optimizebooleanNotrueApply optimization recommendations

Core Instructions

Instruction Reference

InstructionPurposeExample
FROMBase imageFROM node:20-alpine
WORKDIRSet working directoryWORKDIR /app
COPYCopy filesCOPY package*.json ./
RUNExecute commandRUN npm ci
ENVSet environmentENV NODE_ENV=production
EXPOSEDocument portEXPOSE 3000
USERSet userUSER appuser
CMDDefault commandCMD ["node", "app.js"]
ENTRYPOINTFixed commandENTRYPOINT ["./start.sh"]
HEALTHCHECKHealth checkHEALTHCHECK CMD curl -f http://localhost/

Layer Optimization Order

# 1. Base image (most stable)
FROM node:20-alpine

# 2. System dependencies
RUN apk add --no-cache curl

# 3. Create user (security)
RUN addgroup -g 1001 app && adduser -u 1001 -G app -D app

# 4. Set working directory
WORKDIR /app

# 5. Copy dependency files (cache layer)
COPY package*.json ./

# 6. Install dependencies
RUN npm ci --only=production

# 7. Copy application code (most volatile)
COPY --chown=app:app . .

# 8. Switch to non-root user
USER app

# 9. Health check
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost:3000/health || exit 1

# 10. Default command
CMD ["node", "server.js"]

Best Practices (2024-2025)

Security Essentials

# Always use specific version tags
FROM node:20.10-alpine  # Good
# FROM node:latest      # Bad

# Run as non-root user
USER nonroot

# Use multi-stage builds
FROM node:20 AS builder
# ... build steps ...
FROM node:20-alpine AS runtime
COPY --from=builder /app/dist ./

Optimization Techniques

# Combine RUN commands
RUN apt-get update && \
    apt-get install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

# Use .dockerignore
# node_modules, .git, *.md, etc.

# Leverage BuildKit cache mounts
RUN --mount=type=cache,target=/root/.npm npm ci

Error Handling

Common Errors

ErrorCauseSolution
COPY failed: file not foundFile outside contextCheck .dockerignore
returned non-zero code: 127Command not foundInstall package first
permission deniedRunning as non-rootUse COPY --chown

Validation Commands

# Lint Dockerfile
hadolint Dockerfile

# Build with no cache
docker build --no-cache -t app:test .

# Inspect layers
docker history app:test

Troubleshooting

Debug Checklist

  • [ ] .dockerignore excludes unnecessary files?
  • [ ] Base image tag is specific (not :latest)?
  • [ ] Dependencies copied before source code?
  • [ ] Non-root user configured?
  • [ ] HEALTHCHECK defined?

Common Issues

SymptomCauseFix
Large image sizeNo multi-stageAdd build stage
Slow buildsPoor layer orderMove COPY after dependencies
Security warningsRoot userAdd USER instruction

Usage

Skill("dockerfile-basics")

Related Skills

  • docker-multi-stage
  • docker-optimization
  • docker-security

Related skills

How it compares

Template-plus-linter skill for Dockerfiles—not a full CI/CD pipeline or Kubernetes deploy package.

FAQ

Who is dockerfile-basics for?

Developers using AI coding agents who are dockerizing a Node app for the first production deploy.

When should I use dockerfile-basics?

In Ship/launch when preparing registry images; in Build/backend when you first add Docker to the repo; before perf or security review if images grew ad hoc.

Is dockerfile-basics safe to install?

It suggests non-root users and linting—review the Security Audits panel on this page and scan images in your registry CI before production.

DevOps & CI/CDdevopsbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.