Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Dockerfile Basics

CSecurity

Learn Dockerfile fundamentals and best practices for building production-ready container images

76 stars
0 votes
0 copies
0 views
Added 2/8/2026
developmentpythongojavabashnodedockergitsecurity

Security Analysis

C72/100
mediumUses curl or wget to download content
criticalAccesses sensitive system or user directories
highPerforms destructive filesystem operations

Scanned 2/12/2026

Install to Claude Code

$npx -y skills add majiayu000/claude-skill-registry --skill dockerfile-basics --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dockerfile Basics?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Dockerfile Basics
[![Security: C — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-dockerfile-basics/badge)](https://www.skillsdirectory.com/skills/majiayu000-dockerfile-basics)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: dockerfile-basics
description: Learn Dockerfile fundamentals and best practices for building production-ready container images
sasmp_version: "1.3.0"
bonded_agent: 01-docker-fundamentals
bond_type: PRIMARY_BOND
---

# 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

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| base_image | string | No | - | Base image to use |
| language | string | No | - | Programming language (node/python/go/java) |
| optimize | boolean | No | true | Apply optimization recommendations |

## Core Instructions

### Instruction Reference
| Instruction | Purpose | Example |
|-------------|---------|---------|
| FROM | Base image | `FROM node:20-alpine` |
| WORKDIR | Set working directory | `WORKDIR /app` |
| COPY | Copy files | `COPY package*.json ./` |
| RUN | Execute command | `RUN npm ci` |
| ENV | Set environment | `ENV NODE_ENV=production` |
| EXPOSE | Document port | `EXPOSE 3000` |
| USER | Set user | `USER appuser` |
| CMD | Default command | `CMD ["node", "app.js"]` |
| ENTRYPOINT | Fixed command | `ENTRYPOINT ["./start.sh"]` |
| HEALTHCHECK | Health check | `HEALTHCHECK CMD curl -f http://localhost/` |

### Layer Optimization Order
```dockerfile
# 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
```dockerfile
# 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
```dockerfile
# 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
| Error | Cause | Solution |
|-------|-------|----------|
| `COPY failed: file not found` | File outside context | Check .dockerignore |
| `returned non-zero code: 127` | Command not found | Install package first |
| `permission denied` | Running as non-root | Use COPY --chown |

### Validation Commands
```bash
# 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
| Symptom | Cause | Fix |
|---------|-------|-----|
| Large image size | No multi-stage | Add build stage |
| Slow builds | Poor layer order | Move COPY after dependencies |
| Security warnings | Root user | Add USER instruction |

## Usage

```
Skill("dockerfile-basics")
```

## Related Skills
- docker-multi-stage
- docker-optimization
- docker-security

Attribution

majiayu000majiayu000
View sourceMore from majiayu000 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284722 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →