صور Docker يتم بناؤها في طبقات — كل تعليمة في Dockerfile تنشئ طبقة، و Docker يخزن مؤقتاً الطبقات لتسريع عمليات البناء الجديدة. فهم الطبقات والتخزين المؤقت هو المفتاح لكتابة ملفات Dockerfile فعالة تبني بسرعة وتنتج صور أصغر.
الطبقات — كل تعليمة تضيف طبقة
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.
