Enable AI-assisted, spec-governed containerization of applications using Docker and Docker AI Agent (Gordon). Use when generating Dockerfiles, validating container configurations, or creating Gordon prompts. Triggers on requests involving Docker setup, container configuration, or deployment preparation.
AI-assisted, spec-governed containerization for applications using Docker and Docker AI Agent (Gordon).
Enable generation of production-ready Dockerfiles and container configurations that:
Use this skill when:
Do NOT use this skill when:
Before generating output, clarify these with the user:
| Component | Supported Versions | Notes | |-----------|-------------------|-------| | Docker Engine | 20.10+ | BuildKit recommended | | Docker Compose | 2.0+ | V2 syntax | | BuildKit | 0.10+ | For advanced features | | Gordon (Docker AI) | Latest | Requires Docker Desktop |
| Runtime | Recommended Base | Size |
|---------|-----------------|------|
| Python 3.11-3.13 | python:3.13-slim | ~150MB |
| Node.js 18-22 | node:22-alpine | ~180MB |
| Go 1.21+ | golang:1.22-alpine | ~250MB |
| Java 17+ | eclipse-temurin:21-jre-alpine | ~200MB |
| Input | Type | Description |
|-------|------|-------------|
| application_role | frontend | backend | The application tier being containerized |
| runtime_requirements | Object | Language, version, dependencies |
| environment_variables | Array | Required env vars (names only, no values) |
| port_exposure | Number | Array | Port(s) the container exposes |
| Input | Type | Default | Description |
|-------|------|---------|-------------|
| base_image | String | Auto-detected | Override base image selection |
| build_args | Object | {} | Build-time arguments |
| healthcheck | Object | null | Health check configuration |
| multi_stage | Boolean | true | Use multi-stage builds |
Dockerfile (generated, NOT executed)
Docker Build Command Suggestions
Docker Run Command Suggestions
Gordon Prompt Suggestions
docker build commands (as documentation)docker run commands (as documentation)docker commandsdocker build, docker run, docker pushlatest tag without explicit user approval.env file mounting# syntax=docker/dockerfile:1
# ============================================
# Stage 1: Builder
# ============================================
FROM python:3.13-slim AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# ============================================
# Stage 2: Production
# ============================================
FROM python:3.13-slim AS production
# Create non-root user
RUN groupadd --gid 1000 appgroup \
&& useradd --uid 1000 --gid appgroup --shell /bin/bash --create-home appuser
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /root/.local /home/appuser/.local
# Copy application code
COPY --chown=appuser:appgroup . .
# Set environment
ENV PATH=/home/appuser/.local/bin:$PATH
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Switch to non-root user
USER appuser
# Expose port (configurable)
EXPOSE ${PORT:-8000}
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:${PORT:-8000}/health')" || exit 1
# Run application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "${PORT:-8000}"]
# syntax=docker/dockerfile:1
# ============================================
# Stage 1: Dependencies
# ============================================
FROM node:20-alpine AS deps
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci --only=production
# ============================================
# Stage 2: Builder
# ============================================
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build arguments for environment
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
# Build the application
RUN npm run build
# ============================================
# Stage 3: Production
# ============================================
FROM node:20-alpine AS production
WORKDIR /app
# Create non-root user
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
# Copy built assets
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
# Backend build (suggested, not executed)
docker build \
--tag myapp-backend:$(git rev-parse --short HEAD) \
--build-arg PORT=8000 \
--file Dockerfile.backend \
--target production \
./backend
# Frontend build (suggested, not executed)
docker build \
--tag myapp-frontend:$(git rev-parse --short HEAD) \
--build-arg NEXT_PUBLIC_API_URL=http://localhost:8000 \
--file Dockerfile.frontend \
--target production \
./frontend
# Backend run (suggested, not executed)
docker run \
--name myapp-backend \
--publish 8000:8000 \
--env-file .env \
--env DATABASE_URL \
--env JWT_SECRET \
--restart unless-stopped \
--detach \
myapp-backend:latest
# Frontend run (suggested, not executed)
docker run \
--name myapp-frontend \
--publish 3000:3000 \
--env-file .env.local \
--restart unless-stopped \
--detach \
myapp-frontend:latest
@gordon optimize this Dockerfile for production:
- Minimize image size
- Reduce build time with layer caching
- Apply security best practices
- Suggest multi-stage improvements
@gordon analyze this Dockerfile for security vulnerabilities:
- Check for hardcoded secrets
- Verify non-root user configuration
- Identify exposed attack surface
- Recommend security hardening
@gordon help debug this container issue:
- Container exits immediately after start
- Environment variables not loading
- Health check failing
- Network connectivity problems
@gordon suggest performance improvements:
- Memory allocation optimization
- CPU limit recommendations
- Build cache strategies
- Image size reduction
@gordon verify this Dockerfile meets these requirements:
- Stateless design (no local state)
- Configuration via environment variables only
- Non-root user execution
- No secrets in build layers
Before finalizing any Dockerfile output, validate against:
VOLUME for application stateENV or ARG.env file support documentedInput:
{
"application_role": "backend",
"runtime_requirements": {
"language": "python",
"version": "3.13",
"framework": "fastapi"
},
"environment_variables": [
"DATABASE_URL",
"JWT_SECRET",
"PORT"
],
"port_exposure": 8000
}
Output: Generated Dockerfile following backend template with FastAPI configuration.
Input:
{
"application_role": "frontend",
"runtime_requirements": {
"language": "javascript",
"version": "20",
"framework": "nextjs"
},
"environment_variables": [
"NEXT_PUBLIC_API_URL"
],
"port_exposure": 3000
}
Output: Generated Dockerfile following frontend template with Next.js standalone output.
This skill integrates with the SDD workflow:
When containerization decisions have long-term impact, suggest:
Architectural decision detected: Container orchestration strategy Document reasoning and tradeoffs? Run
/sp.adr container-strategy
npx skills add assadsharif/docker-containerization下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer