LABEL: Metadata Management
What you'll learn: How to attach descriptive metadata to your Docker images using the LABEL instruction.
What is LABEL?
The LABEL instruction in a Dockerfile adds key-value pairs of metadata to your container image. Think of labels as sticky notes you attach to a box—they don't change what's inside, but they help you organize, document, and manage your images later.
Core Concept
Labels store information about the image: who maintains it, what version it is, where the source code lives, or any other descriptive data. This metadata travels with the image wherever it goes.
Basic syntax:
LABEL key="value"
LABEL version="1.0.0"
LABEL maintainer="devops@example.com"
You can also define multiple labels in one instruction:
LABEL version="1.0.0" \
maintainer="devops@example.com" \
description="Web application backend"
Common Label Patterns
The container community has established conventional label names:
maintainer- Image maintainer contactversion- Application versiondescription- Human-readable descriptionorg.opencontainers.image.source- Source repository URLorg.opencontainers.image.licenses- License information
Querying Labels
After building an image, inspect its labels:
docker image inspect myimage:latest
Filter to view only labels:
docker image inspect --format='{{json .Config.Labels}}' myimage:latest
Labels also enable filtering operations, letting you organize and query images by metadata rather than just names or tags.
Key Takeaway: LABEL instructions add searchable metadata to images for documentation, organization, and automation—they're invisible at runtime but invaluable for image management.