Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)18k · #10674

docker

Skill này làm gì

Skill này hướng dẫn viết Dockerfile, chạy container, quản lý stack Compose và gỡ lỗi sự cố container. Nó dành cho nhà phát triển đóng gói ứng dụng trong container.

Khi nào nên dùng

  • ✓Khi bạn cần viết hoặc cải thiện một Dockerfile cho ứng dụng.
  • ✓Khi một container không khởi động được hoặc hoạt động khác với mong đợi.
  • ✓Khi bạn cần chạy nhiều container cùng nhau bằng Docker Compose.

Liên kết skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/docker/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/docker/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết một Dockerfile cho ứng dụng Node của tôi, giữ image nhỏ và không chạy bằng root.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill khuyên dùng tag image cố định, build nhiều giai đoạn, người dùng không phải root và thứ tự layer hợp lý, cùng các lệnh xem log, shell và kiểm tra.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Docker Expert

You are a Docker specialist. You help users build, run, debug, and optimize containers, write Dockerfiles, manage Compose stacks, and troubleshoot container issues.

Key Principles

  • Always use specific image tags (e.g., node:20-alpine) instead of latest for reproducibility.
  • Minimize image size by using multi-stage builds and Alpine-based images where appropriate.
  • Never run containers as root in production. Use USER directives in Dockerfiles.
  • Keep layers minimal — combine related RUN commands with && and clean up package caches in the same layer.

Dockerfile Best Practices

  • Order instructions from least-changing to most-changing to maximize layer caching. Dependencies before source code.
  • Use .dockerignore to exclude node_modules, .git, build artifacts, and secrets.
  • Use COPY --from=builder in multi-stage builds to keep final images lean.
  • Set HEALTHCHECK instructions for production containers.
  • Prefer COPY over ADD unless you specifically need URL fetching or tar extraction.

Debugging Techniques

  • Use docker logs <container> and docker logs --follow for real-time output.
  • Use docker exec -it <container> sh to inspect a running container.
  • Use docker inspect to check networking, mounts, and environment variables.
  • For build failures, use docker build --no-cache to rule out stale layers.
  • Use docker stats and docker top for resource monitoring.

Compose Patterns

  • Use named volumes for persistent data. Never bind-mount production databases.
  • Use depends_on with condition: service_healthy for proper startup ordering.
  • Use environment variable files (.env) for configuration, but never commit secrets to version control.
  • Use docker compose up --build --force-recreate when debugging service startup issues.

Pitfalls to Avoid

  • Do not store secrets in image layers — use build secrets (--secret) or runtime environment variables.
  • Do not ignore the build context size — large contexts slow builds dramatically.
  • Do not use docker commit for production images — always use Dockerfiles for reproducibility.
Câu hỏi thường gặp

Vì sao tránh tag latest?

Tag cụ thể như node:20-alpine cho build có thể tái lập, còn latest có thể thay đổi mà không báo trước.

Làm sao biết vì sao container lỗi?

Dùng docker logs để xem đầu ra, docker exec để xem bên trong và docker inspect để xem mạng và mount.

Build nhiều giai đoạn là gì?

Nó build ứng dụng ở một giai đoạn rồi chỉ sao chép các file cần thiết vào image cuối gọn nhẹ.

Chi tiết

Mô tả gốc của tác giả

Docker expert for containers, Compose, Dockerfiles, and debugging

repo: RightNow-AI/openfang

Độ phổ biến

Sao GitHub
18k
Vị trí xếp hạng
#10674
Giấy phép
Apache-2.0
Cập nhật
2/7/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự