Docker image ถูก build เป็น layer — แต่ละคำสั่งใน Dockerfile สร้าง layer และ Docker cache layer เพื่อเร่งการ rebuild การเข้าใจ layer และ caching เป็นกุญแจสำคัญในการเขียน Dockerfile ที่มีประสิทธิภาพซึ่ง build เร็วและสร้าง image ที่เล็กลง
Layer — แต่ละคำสั่งเพิ่ม layer
Each Dockerfile instruction (FROM, RUN, COPY, etc.) creates a read-only LAYER:
→ layers stack to form the image; layers are CACHED and SHARED between images
→ if a layer is unchanged, Docker REUSES the cached layer (skips rebuilding it)
→ Layer caching makes rebuilds fast — only changed layers (and those AFTER) rebuild.
