Skip to content
docker logo

Docker Development Skill

docker

Container-based development for isolated, reproducible environments. Use when running npm commands, installing packages, executing code, or managing project dependencies. Trigger phrases include "npm install", "run the build", "start the server", "install package", or any code execution request.

SKILL.md

Full skill instructions

Docker Development Skill

Execute all package installations and code execution inside Docker containers. This keeps the host machine clean and ensures consistent environments across projects.


Behavioral Classification

Type: Autonomous Execution

Directive: EXECUTE, DON'T ASK

This skill enforces Docker-first development automatically. When you request npm/​node operations, commands are executed inside Docker without asking for permission.

Enforcement Behavior:

  • Blocks host-machine npm/​node commands
  • Suggests or transforms commands to use docker exec
  • Automatically checks container status before operations

Quick Start

For new projects, see setup.md for the complete first-time setup guide.

Minimal setup:

# 1. Start container
docker compose --profile dev up -d

# 2. Verify running
docker ps --filter "name=my-project"

# 3. Run commands in container
docker exec my-project-dev-1 npm install
docker exec my-project-dev-1 npm test
docker exec my-project-dev-1 npm run build

ENFORCEMENT RULES

BLOCKED: Never Run on Host

These commands are BLOCKED on the host machine:

npm install, npm ci, npm run, npm test, npm exec
npx <anything>
yarn add, yarn install, yarn run
pnpm add, pnpm install, pnpm run
node <script>
tsx <script>
bun <script>

Why? Installing packages on the host:

  • Pollutes the host machine with project-specific dependencies
  • Creates version conflicts between projects
  • Makes environments non-reproducible
  • Can cause security issues with global packages

REQUIRED: Use docker exec

All Node.js commands MUST use this prefix:

docker exec <container-name> <command>

Note: Use docker exec WITHOUT the -it flag in Claude Code:

# Correct (works in Claude Code)
docker exec my-project-dev-1 npm run build

# Wrong (fails with "not a TTY")
docker exec -it my-project-dev-1 npm run build

Pre-Flight Check (MANDATORY)

Before running ANY npm/​node command, verify the container is running.

docker ps --filter "name=<container-name>" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

Expected output:

NAMES                   STATUS          PORTS
my-project-dev-1        Up X minutes    0.0.0.0:3000->3000/​tcp

If container is NOT running:

cd /​path/​to/​project
docker compose --profile dev up -d
docker ps --filter "name=<container-name>"

If container shows "Exited":

docker logs <container-name> --tail 20
docker compose --profile dev down
docker compose --profile dev up -d

Quick Reference

Check Container Status

docker ps --filter "name=<container-name>"
docker logs <container-name> --tail 50
curl -s http://localhost:<port> > /​dev/​null && echo "Running" || echo "Not running"

Start/​Stop Containers

docker compose --profile dev up -d        # Start
docker compose --profile dev down         # Stop
docker compose --profile dev restart dev  # Restart
docker compose --profile dev up -d --build  # Rebuild

Execute Commands Inside Container

docker exec <container> npm install <package>     # Install package
docker exec <container> npm install -D <package>  # Install dev dependency
docker exec <container> npm test                  # Run tests
docker exec <container> npm run typecheck         # Type checking
docker exec <container> npm run lint              # Linting
docker exec <container> npm run build             # Build
docker exec <container> /​bin/​sh                   # Shell (use -it for interactive)

When to Use docker exec

OperationUse docker exec?Reason
npm installAlwaysPackages install in container only
npm run devNoAlready running via docker-compose
npm testYesTests run in container environment
npm run buildYesBuild happens in container
git commandsNoGit runs on host (manages files)
File editingNoVolume mount syncs automatically
Database migrationsYesUses container's Node environment

Container Architecture

┌─────────────────────────────────────────────────────────────┐
│  HOST (macOS/​Linux/​Windows)                                 │
│                                                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  Docker Container (my-project-dev-1)                │   │
│  │                                                     │   │
│  │  Node 20 (Slim or Alpine)                           │   │
│  │  └── node_modules/ (container-only, NOT on host)    │   │
│  │  └── Dev server (port 3000)                         │   │
│  │                                                     │   │
│  │  Volume Mounts:                                     │   │
│  │  └── .:/​app (source code sync)                      │   │
│  │  └── node_modules:/​app/​node_modules (persist deps)  │   │
│  └─────────────────────────────────────────────────────┘   │
│                         │                                   │
│                         ▼                                   │
│                   Port mapped                               │
│                         │                                   │
│                         ▼                                   │
│              http://localhost:<port>                        │
└─────────────────────────────────────────────────────────────┘

Key Point: node_modules exists ONLY in the container. The host machine stays clean.


Volume Mount Behavior

volumes:
  - .:/​app                           # Source code (synced)
  - node_modules:/​app/​node_modules   # Dependencies (container-only)

What this means:

  • Source code changes on host are immediately visible in container
  • node_modules/ lives in a named Docker volume, NOT on host filesystem
  • Hot reload works automatically
  • Host machine never has project dependencies installed

Troubleshooting

Container Not Running

docker ps -a --filter "name=<container-name>"
docker logs <container-name>
docker compose --profile dev up -d

Port Already in Use

lsof -i :<port>
# Kill the process or change port in docker-compose.yml

Module Not Found Errors

docker compose --profile dev down
docker compose --profile dev build --no-cache
docker compose --profile dev up -d
docker exec <container> npm install

File Changes Not Reflecting

docker inspect <container-name> | grep -A 10 "Mounts"
docker compose --profile dev restart dev

Wrong Architecture (M1/​M2 Mac)

If you see platform warnings:

# Add to docker-compose.yml service
platform: linux/​amd64  # or linux/​arm64

Native Module Errors

See setup.md for the complete native module troubleshooting guide including:

  • ERR_DLOPEN_FAILED resolution
  • Alpine vs Slim decision tree
  • Rebuild instructions

Best Practices

  1. Always check container status before running commands
  2. Use docker exec for ALL npm/​node operations
  3. Never install packages on host - always in container
  4. Use node:20-slim by default - switch to alpine only if no native modules
  5. Rebuild image after changing package.json or Dockerfile
  6. Check logs when something isn't working
  7. Use named volumes for node_modules to persist between container restarts

Health Checks

For automated health monitoring and CI integration, see health-checks.md:

  • Container healthcheck configuration
  • Health check shell script
  • NPM scripts integration
  • Troubleshooting health failures

Integration with Claude Code

TaskAction
Install dependencydocker exec <container> npm install <pkg>
Run testsdocker exec <container> npm test
Check typesdocker exec <container> npm run typecheck
Build projectdocker exec <container> npm run build
Start dev serverContainer already runs it via docker-compose
Edit filesEdit directly (volume mount syncs)
Git operationsRun on host (not in container)

Related Skills

For complete Docker development support, use with these complementary skills:

SkillPurpose
docker-enforceAutomatically blocks/​transforms host commands to run inside Docker
docker-optimizerAnalyzes Dockerfiles for optimization opportunities
docker-guardPrevents hangs when Docker daemon is unresponsive

docker-enforce

Provides automated enforcement of Docker-first policy:

  • Intercepts npm, npx, yarn, pnpm, node, tsx, bun commands
  • Blocks commands on host with suggestion to use docker exec
  • Can auto-transform commands to run inside container
  • Configurable allowlist for safe host commands

Install: git clone https://github.com/​wrsmith108/​docker-enforce.git ~/​.claude/​skills/​docker-enforce


Reference Documentation

DocumentContents
setup.mdFirst-time setup, native module troubleshooting, project configuration
health-checks.mdContainer healthchecks, monitoring scripts, NPM integration

Changelog

v1.1.0 (2026-01-23)

  • Refactor: Decompose into sub-files for progressive disclosure
  • Extract first-time setup to setup.md
  • Extract health checks to health-checks.md
  • Add Behavioral Classification section (ADR-025)
  • Main SKILL.md reduced from 718 to ~320 lines

v1.0.0 (2025-01)

  • Initial release
  • Docker-first enforcement rules
  • Container architecture documentation
  • Troubleshooting guide

Last updated: January 2026

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View