Latest tag

2 snippets across 2 stacks — Docker, Git

DKDocker

Not Pinning Image Versions

DK · Common Mistakes
syntax
# Problem:
FROM node:latest
FROM python
FROM nginx
example
# Fix — pin to specific versions:
FROM node:20.11.1-alpine3.19
FROM python:3.12.2-slim-bookworm
FROM nginx:1.25.4-alpine

Note An image tag like :latest or :20 can change at any time. Your build might work today and fail tomorrow because the base image was updated. In CI, a non-reproducible build means you cannot investigate a production issue with the exact same image.

GitGit

Find the Latest Tag

Git · Tags
syntax
git describe --tags --abbrev=0
git describe --tags
example
git describe --tags --abbrev=0
git describe --tags
output
v2.0.0
v2.0.0-3-ga1b2c3d

Note --abbrev=0 gives just the tag name. Without it, Git also shows how many commits since that tag and the current abbreviated hash. Useful in CI/CD for version stamping.