본문으로 건너뛰기
cccskills
무료GitHub에 공개

docker-helper

Build, debug, and optimize Docker configurations. Use when a user asks to create a Dockerfile, fix Docker build errors, optimize image size, write docker-compose files, debug container issues, set up multi-stage builds, or troubleshoot networking between containers. Covers Dockerfile best practices and compose orchestration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구DockerPostgreSQL
설치 방법 보기

포함된 파일(2)

  • SKILL.md8.3 KB
  • _scores.json2.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Docker Helper

Overview

Create, debug, and optimize Docker configurations including Dockerfiles, docker-compose setups, and container troubleshooting. Follows Docker best practices for security, image size, and build speed.

Instructions

When a user asks for help with Docker, determine which task they need:

Task A: Create a Dockerfile

  1. Identify the application language and framework. docker init can generate a starting Dockerfile, compose.yaml and .dockerignore for common stacks; review its output before keeping it.
  2. Choose the right base image (prefer -slim or -alpine variants, and a currently supported release: Node 20 reached end of life in April 2026, so use an LTS such as 24 or 22).
  3. Use multi-stage builds for compiled or bundled apps.
  4. Order instructions for layer caching:
# Stage 1: build (needs dev dependencies)
FROM node:24-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build && npm prune --omit=dev

# Stage 2: runtime
FROM node:24-alpine
ENV NODE_ENV=production
WORKDIR /app
COPY --from=builder --chown=node:node /app/dist ./dist
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
COPY --from=builder --chown=node:node /app/package.json ./
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]

The official Node images already ship a non-root node user. Installing with npm ci --omit=dev in the builder would break npm run build when the build tool is a dev dependency; prune afterwards instead. (--only=production is the deprecated spelling of --omit=dev.)

Key rules:

  • Copy dependency files first, then source (caching)
  • Run as a non-root user (USER before CMD)
  • Use .dockerignore to exclude node_modules, .git, .env
  • Pin base images to a version tag (e.g. node:24.8-alpine); for reproducible builds pin the digest too (image@sha256:...)
  • Chain related RUN steps with && so cleanup happens in the same layer

Task B: Write compose.yaml

Docker Compose v2 is the docker compose plugin (not the old docker-compose binary). The top-level version: key is obsolete and only produces a warning; omit it. The preferred file name is compose.yaml (docker-compose.yml is still read).

services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgres://orders:${POSTGRES_PASSWORD:?set it in .env}@db:5432/orders
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    image: postgres:18-alpine
    volumes:
      - pgdata:/var/lib/postgresql
    environment:
      POSTGRES_USER: orders
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set it in .env}
      POSTGRES_DB: orders
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U orders -d orders"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  pgdata:

Run it with docker compose up -d --wait (waits until services are healthy), check with docker compose ps, and validate the merged file with docker compose config.

Key rules:

  • Use depends_on with condition: service_healthy, not just service names
  • Use named volumes for persistent data. Postgres 18 images keep data in a versioned subdirectory of /var/lib/postgresql, so mount the volume there; for 17 and older the mount point is /var/lib/postgresql/data
  • Keep secrets out of the file: read them from .env (interpolation, as above) or use Compose secrets:
  • Set restart policies
  • For local development, docker compose watch with a develop.watch section syncs or rebuilds on file changes

Task C: Debug container issues

Follow this diagnostic sequence:

# 1. Check container status
docker ps -a

# 2. Read container logs
docker logs web --tail 50

# 3. Inspect container details (exit code, OOM kill, health)
docker inspect --format '{{json .State}}' web

# 4. Check resource usage
docker stats --no-stream

# 5. Get a shell inside the container
docker exec -it web /bin/sh

# 6. Check networking
docker network ls
docker network inspect orders_default

For Compose projects, use docker compose logs -f app and docker compose ps. If the image has no shell, docker run --rm -it --entrypoint sh <image> or docker debug <container> (Docker Desktop / subscription feature) helps.

Common issues and fixes:

  • Container exits immediately: check logs; usually a missing env var or config file. docker inspect shows ExitCode (137 usually means killed, often out of memory)
  • Port already in use: lsof -i :3000 to find the conflict
  • Cannot connect between containers: put them on the same network and use service names as hostnames, never localhost
  • Out of disk space: docker system df shows usage; docker system prune removes stopped containers, unused networks and dangling images. Add -a (all unused images) or --volumes only after checking what they will delete, since volumes hold data
  • Build fails at COPY: check .dockerignore and verify paths are relative to the build context

Task D: Optimize image size

# Check current image size
docker images myapp

# Analyze layers
docker history myapp:latest

Optimization checklist:

  1. Switch to slim or alpine base images (alpine uses musl; some Python wheels and native Node modules need a glibc -slim image instead)
  2. Use multi-stage builds (build deps stay in the builder stage)
  3. Combine RUN commands with &&
  4. Remove package manager caches in the same layer (rm -rf /var/cache/apk/*, or apk add --no-cache; apt-get ... && rm -rf /var/lib/apt/lists/*)
  5. Use .dockerignore to exclude test files, docs, .git
  6. Do not install dev dependencies in the final image

Examples

Example 1: Create a Dockerfile for a Python FastAPI app

User request: "Create a Dockerfile for my FastAPI project"

Output Dockerfile:

FROM python:3.14-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

FROM python:3.14-slim
WORKDIR /app
RUN useradd -r -s /usr/sbin/nologin appuser
COPY --from=builder /install /usr/local
COPY . .
USER appuser
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Output .dockerignore:

__pycache__
*.pyc
.git
.env
.venv
tests/
*.md

Result: Image size ~180MB instead of ~1.2GB with the full Python image.

Example 2: Debug a container that keeps restarting

User request: "My web container keeps restarting, can you help?"

Diagnostic steps:

$ docker ps -a
CONTAINER ID  IMAGE    STATUS                     NAMES
a1b2c3d4e5f6  web:1.0  Restarting (1) 5 sec ago   web

$ docker logs web --tail 20
Error: ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect

Root cause: The app is trying to connect to PostgreSQL at 127.0.0.1,
but in Docker the database is a separate container.

Fix: Change DATABASE_URL from localhost to the service name:
  DATABASE_URL=postgres://orders:${POSTGRES_PASSWORD}@db:5432/orders
                                           ^^ service name, not localhost

Guidelines

  • Always create a .dockerignore alongside any Dockerfile.
  • Pin base image versions to specific tags, not latest, and move off end-of-life releases.
  • Never store secrets in Docker images or Dockerfiles. Use environment variables or Docker secrets.
  • For production, always run as a non-root user.
  • When optimizing, measure before and after with docker images.
  • If a build is slow, check layer ordering. Dependencies (package.json, requirements.txt) should be copied and installed before source code.
  • For local development, use bind mounts for live reloading. For production, use COPY.
  • Health checks should test actual application readiness, not just process existence.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Scripts and configures production rendering in Autodesk 3ds Max with the V-Ray and Corona renderers: output size and files, render elements, denoising, light mix, batch and command-line rendering, and network rendering. Use when a user asks to set up a production render, render several cameras in one batch, render from the command line or on a render farm, add render passes for compositing, or cut render time for archviz and product shots.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

Covers scripting Autodesk 3ds Max, the 3D modeling and rendering application, with MAXScript and Python (pymxs): scene manipulation, object creation, material assignment, camera and light setup, batch operations, and file I/O. Use when tasks involve automating repetitive 3ds Max workflows, batch processing scenes, running scripts headless with 3dsmaxbatch, creating custom tools, or scripting scene setup for archviz, product visualization, or VFX.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

3proxy

무료

3proxy is a small open-source proxy server that runs HTTP/HTTPS, SOCKS4/5, SNI and TCP/UDP port-mapping proxies from one config file. Use when a user asks to set up an HTTP or SOCKS5 proxy, add proxy users and passwords, write 3proxy access rules, chain or rotate upstream (parent) proxies, limit bandwidth, connections or monthly traffic per user, run 3proxy in Docker, or fix a 3proxy.cfg that will not start.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

Builds Agent2Agent (A2A) servers and clients, the open protocol (originally from Google, now under the Linux Foundation) that lets AI agents from different frameworks call each other. Use when the user wants to create an A2A-compliant agent, build an Agent Card, implement task management, connect agents across frameworks, set up agent discovery, handle streaming responses, implement push notifications, or orchestrate multi-agent workflows. Trigger words: a2a, agent to agent, agent2agent, a2a protocol, a2a server, a2a client, agent card, agent interoperability, agent collaboration, multi-agent, agent discovery, a2a sdk, a2a task.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

Plans a controlled experiment (A/B test) so its result can be trusted: writes the hypothesis, picks one primary metric and the guardrails, computes sample size and run time, specifies how visitors are assigned and when exposure is logged, and reads out the result with a confidence interval. Use when someone says "set up an A/B test", "split test this page", "how many visitors do I need", "how long should the experiment run", "is this result significant", "can I stop the test early", or wants to test a headline, price, layout or onboarding change against the current version.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

ably

무료

Ably is a hosted realtime messaging service: clients publish and subscribe to named channels over WebSockets, see who is present, replay message history, and resume after a dropped connection. Use when a user asks to "add realtime updates", "push live notifications to the browser", "show who is online", "add a chat room with typing indicators", "publish from a serverless function", or "authenticate Ably clients without exposing the API key". Covers the ably 2.x JavaScript SDK (Realtime and REST), JWT token authentication, presence, history and rewind, batch publishing, and the @ably/chat 1.x SDK.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

TerminalSkills의 스킬 모두 보기

이 스킬의 문제 신고