Skip to content

A CI/CD pipeline with Docker

Select an icon to see what it is.

Step 6 of 6

Why the commit id is the tag

A tag like latest moves, so it does not say what is running. A commit-id tag always points to one build, so you can trace a running container to its commit. Rolling back is a deploy of the previous commit's tag, and a healthcheck on the new version tells you whether it came up.

PrevNext

Rollback

running now: registry.example.com/shop/web:3f9a1c2
roll back: TAG=<previous commit id> docker compose up -d

Try it yourself

Run the build, test and tag steps of the pipeline on your own machine. Pushing needs a registry login, so the push is left out.

$ TAG=$(date +%s)
$ printf 'FROM alpine\nCMD ["echo", "app running"]\n' > Dockerfile
$ docker build -t registry.example.com/shop/web:$TAG .
$ docker run --rm registry.example.com/shop/web:$TAG
$ docker image ls 'registry.example.com/shop/web'
$ docker rmi registry.example.com/shop/web:$TAG

Quiz

1. Why tag the image with the commit id?
2. Where should the registry password come from in a pipeline?
3. What stops a vulnerable image from being deployed?