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
docker pull nginx:1.27-alpine
docker images
docker image inspect nginx:1.27-alpine
docker history nginx:1.27-alpine
pulldownloads an image from a registry.imageslists local images.inspectshows configuration as structured data.historyshows the commands and sizes that created the image.
Remove an unused image:
docker rmi nginx:1.27-alpine
If a container uses the image, Docker may prevent removal until the container is removed.
Image versus container
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.
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

