Docker Images
Tags and Digests
Tags are human-friendly aliases for specific image versions.
When we pull an image like Alpine, Docker downloads a specific tag of that image; even if it's not explicitly mentioned, Docker assumes the latest tag by default.
docker pull alpine
# is equivalent to
docker pull alpine:latest
Using latest is not a good practice because of two main reasons:
latestdoesn't necessarily mean that you're downloading the latest version of the image. If the developer of the image doesn't update thelatesttag to point to the newest version, you may end up pulling an older version unknowingly.Pulling a dynamic tag like
latestis never a good idea since you don't know what you're getting. The image behind thelatesttag can change over time, leading to inconsistencies in your deployments. It's better to use a fixed tag and when upgrading your Docker image, you just need to change the tag to the new version explicitly.
Examples:
# Pull the tag 3.23.2
docker pull alpine:3.23.2
# Pull the tag 3.22
docker pull alpine:3.22
# Pull the tag 3.21
docker pull alpine:3.21
# ..and so onPainless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
