Back to roadmaps docker Course

Managing Images: Pulling, Listing, and Removing

A Docker image is a read-only template containing the operating system, runtime, libraries, and application files needed to run a container. Let us explore how to manage these templates.


1. Core Image Commands

# Download an image from Docker Hub without running it
docker pull node:20-alpine

# List all downloaded images stored on your machine
docker images

# Delete an unused image from local storage
docker rmi node:20-alpine

2. The Layered File System (UnionFS)

Docker images are composed of read-only layers stacked on top of each other. When you modify an image or write a Dockerfile, you add a new layer:

graph TD
    A[Writeable Container Layer] --> B[Layer 3: App Source Code]
    B --> C[Layer 2: Node.js Runtime Environment]
    C --> D[Layer 1: Base Alpine Linux OS]
  • Shared Layers: If two different images share the same base layer (for example, alpine), Docker downloads that layer only once, saving disk space and download time.
  • Copy-on-Write: When a container runs, Docker adds a temporary, writeable layer on top of the read-only image layers. Any files modified by the running application are copied to this writeable layer, leaving the underlying image unchanged.
Published on Last updated: