Bạn từng gõ docker run và nó chạy, nhưng không hiểu tại sao. Bạn từng copy Dockerfile từ tutorial, build ra image 1.2GB, pull mất 2 phút. Bạn từng restart container và mất toàn bộ database vì không mount volume.

Loạt bài Docker thực chiến không dạy bạn “Docker là gì” — mà dạy bạn dùng Docker đúng trong development và production. Mỗi bài là một vấn đề thực tế, kèm lệnh debug, code mẫu, và những sai lầm mình đã trả giá bằng production incidents.

Kiến thức nền

Loạt bài giả định bạn đã cài Docker và quen CLI cơ bản. Nếu chưa, cài Docker Desktop và chạy docker run hello-world trước.

Các bài viết liên quan trong blog:


Giai đoạn 1: Nền móng

Hiểu Docker thực sự chạy như thế nào trước khi viết Dockerfile.

  1. Phần 1: Kiến trúc Docker & CLI contextEngine, daemon, client, registry, Docker context, socket security
  2. Phần 2: Namespace & cgroup: nền móng containerPID, network, mount, user namespace, cgroup v2, CoW filesystem

Giai đoạn 2: Core Docker

Làm chủ image, Dockerfile, và container lifecycle.

  1. Phần 3: Image, layer & pull/inspectImage manifest, layer model, tagging strategy, pull/push flow, dive
  2. Phần 4: Dockerfile thực chiếnFROM, RUN, COPY, ADD, CMD, ENTRYPOINT, ARG, ENV, WORKDIR, USER, .dockerignore
  3. Phần 5: Container lifecycle & signal handlingStates, stop flow, SIGTERM/SIGKILL, PID 1, restart policy, graceful shutdown

Giai đoạn 3: Dữ liệu & Vận hành

Persist dữ liệu, quản lý log, và đảm bảo container thực sự healthy.

  1. Phần 6: Volume, bind mount & tmpfsNamed volume vs bind mount, backup strategy, permission, volume driver
  2. Phần 7: Logging & debugging containerLog driver, rotation, docker exec, debug distroless container
  3. Phần 8: Healthcheck & autoheal patternHEALTHCHECK, health status, autoheal sidecar, readiness vs liveness

Giai đoạn 4: Multi-container

Quản lý nhiều service với Docker Compose và networking.

  1. Phần 9: Docker Compose cơ bảnService definition, networks, volumes, environment, depends_on, CLI commands
  2. Phần 10: Docker Compose nâng caoProfiles, extends, include, secrets, Compose v5, dev/staging/prod parity
  3. Phần 11: Docker networking: hands-on debugBridge, overlay, host, DNS, service discovery, MTU, troubleshooting

Giai đoạn 5: Production

Từ CI/CD đến resource management và security.

  1. Phần 12: Docker trong CI/CDBuild cache, BuildKit, multi-arch, registry strategy, GitHub Actions, image scanning
  2. Phần 13: Production: resource limit & OOMMemory/CPU limits, OOM killer, init process, real-world sizing
  3. Phần 14: Docker security: capabilities đến rootlessCapability dropping, seccomp, AppArmor, read-only FS, rootless mode

Giai đoạn 6: Reference

  1. Phần 15: Docker troubleshooting: 20 vấn đề thường gặpCatalogue diagnostic: triệu chứng → nguyên nhân → debug → fix

Bonus: Tối ưu Dockerfile

  1. Phần 16: Tối ưu Dockerfile: từ lý thuyết đến benchmarkSystematic approach 5 bước: base image → .dockerignore → layer ordering → gộp RUN → multi-stage, benchmark 1.4GB → 87MB

Loạt liên quan