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:
- Podman: khi nào nên dùng thay Docker — so sánh Docker với Podman
- Container image nhẹ và an toàn — deep dive multi-stage builds, distroless, CVE scan
- Mạng trong Docker — fundamentals về bridge, NAT, publish port
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.
- Phần 1: Kiến trúc Docker & CLI context — Engine, daemon, client, registry, Docker context, socket security
- Phần 2: Namespace & cgroup: nền móng container — PID, network, mount, user namespace, cgroup v2, CoW filesystem
Giai đoạn 2: Core Docker
Làm chủ image, Dockerfile, và container lifecycle.
- Phần 3: Image, layer & pull/inspect — Image manifest, layer model, tagging strategy, pull/push flow, dive
- Phần 4: Dockerfile thực chiến — FROM, RUN, COPY, ADD, CMD, ENTRYPOINT, ARG, ENV, WORKDIR, USER, .dockerignore
- Phần 5: Container lifecycle & signal handling — States, 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.
- Phần 6: Volume, bind mount & tmpfs — Named volume vs bind mount, backup strategy, permission, volume driver
- Phần 7: Logging & debugging container — Log driver, rotation, docker exec, debug distroless container
- Phần 8: Healthcheck & autoheal pattern — HEALTHCHECK, 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.
- Phần 9: Docker Compose cơ bản — Service definition, networks, volumes, environment, depends_on, CLI commands
- Phần 10: Docker Compose nâng cao — Profiles, extends, include, secrets, Compose v5, dev/staging/prod parity
- Phần 11: Docker networking: hands-on debug — Bridge, overlay, host, DNS, service discovery, MTU, troubleshooting
Giai đoạn 5: Production
Từ CI/CD đến resource management và security.
- Phần 12: Docker trong CI/CD — Build cache, BuildKit, multi-arch, registry strategy, GitHub Actions, image scanning
- Phần 13: Production: resource limit & OOM — Memory/CPU limits, OOM killer, init process, real-world sizing
- Phần 14: Docker security: capabilities đến rootless — Capability dropping, seccomp, AppArmor, read-only FS, rootless mode
Giai đoạn 6: Reference
- Phần 15: Docker troubleshooting: 20 vấn đề thường gặp — Catalogue diagnostic: triệu chứng → nguyên nhân → debug → fix
Bonus: Tối ưu Dockerfile
- Phần 16: Tối ưu Dockerfile: từ lý thuyết đến benchmark — Systematic approach 5 bước: base image → .dockerignore → layer ordering → gộp RUN → multi-stage, benchmark 1.4GB → 87MB
Loạt liên quan
- Mạng máy tính & DevOps — networking fundamentals, Docker networking basics
- Linux Ops thực hành — process, signal, filesystem, FHS
- Kubernetes cho Developer — từ container lên orchestration