SkillSprout
Chapter 1 · Lesson 7
Beginner
2 min read

Images, Tags and Layers

Overview

An image is a stack of read-only filesystem layers plus configuration. Docker uses layers to avoid storing and downloading identical file sets repeatedly. A container adds a new writable layer above those read-only image layers.

An image reference has a name and optional tag. nginx:alpine means repository nginx and tag alpine. A tag is a human-readable pointer to an image, not a permanent guarantee. Use a version or digest for repeatable releases.

Detailed Notes

Pull and inspect

bash
docker pull nginx:1.27-alpine
docker images
docker image inspect nginx:1.27-alpine
docker history nginx:1.27-alpine
  • pull downloads an image from a registry.
  • images lists local images.
  • inspect shows configuration as structured data.
  • history shows the commands and sizes that created the image.

Remove an unused image:

bash
docker rmi nginx:1.27-alpine

If a container uses the image, Docker may prevent removal until the container is removed.

Image versus container

text
Dockerfile
   |
   v
Immutable image layers
   |
   v
Container instance
   |
   v
Writable container layer

Changes made with docker exec modify the container's writable layer. They do not change the image and disappear when the container is removed.

Image layers and writable layer
Architecture
Container Awritable layerContainer Bwritable layerSharedread-only imag…OS + runtime + app
Key point. Docker loads shared image layers.

All containers from one image share read-only layers but get separate writable layers.

Common Interview Questions

Finished this lesson?

0 of 27 lessons done · 0% of the course