Cloud Computing Docker Subjective
Sep 30, 2025

Explain Docker image layers and how they work.

Detailed Explanation
Docker images are built in layers using a union filesystem. Each Dockerfile instruction creates a new layer. How layers work: 1) Each layer is read-only, 2) Layers are stacked on top of each other, 3) Changes create new layers, 4) Layers are shared between images, 5) Only changed layers need to be downloaded. Example: FROM ubuntu:20.04 (Layer 1), RUN apt-get update (Layer 2), RUN apt-get install -y nginx (Layer 3), COPY index.html /var/www/html/ (Layer 4). Benefits: Efficient storage (shared layers), Faster builds (cached layers), Faster downloads (only new layers), Version control for images. Best practices: Combine RUN commands to reduce layers, Order instructions by change frequency, Use .dockerignore to exclude unnecessary files.
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback